Modding Help Overriding NPC (Pet) Movement

Discussion in 'Mods' started by Consillium, Apr 9, 2016.

Tags:
  1. Consillium

    Consillium Poptop Tamer

    Hi all,

    I'm currently working on a SMAPI mod that would result in your pet following you around your farm (and perhaps eventually beyond), however working with movement and animation has been challenging. I've managed to get my cat to walk towards me using the following:

    Code:
                if (followingPlayer)
                {
                    if (farmer.Equals(Utility.isThereAFarmerWithinDistance(pet.getTileLocation(), 10)))
                    {
                        var velocity = Utility.getVelocityTowardPoint(pet.position, farmer.position, 3);
                        pet.xVelocity = velocity.X;
                        pet.yVelocity = velocity.Y * -1;
                        pet.faceGeneralDirection(farmer.position, 0);
                        pet.animateInFacingDirection(Game1.currentGameTime);
                    }
                }
    However, I notice that the animation isn't always correct (i.e. standing still animation while moving) and it will rapidly try and face a different direction every few seconds. I'm guessing this is because it's internal update method is trying to do it's own thing.

    If anyone has any suggestions on how to temporarily override the movement for an NPC, I would appreciate it :)
     
      Last edited: Apr 9, 2016
    • taintedwheat

      taintedwheat Master Astronaut

      Dude, I hope someone helps you with this!!
      Also, if you could maybe look into having multiple types of the same pet (different breeds tho) in smapi too would be bossss o:
       
      • Consillium

        Consillium Poptop Tamer

        I definitely wouldn't mind looking into it once I've gotten pass some of the initial hurdles of what I'm working on :D
         

        Share This Page