c# - Unity3D Character glitching -


having trouble glitch in character , animator: https://www.dropbox.com/s/pigrfr98p7oscx3/img_1876.mov?dl=0

i have c# script toggles between pawn piece , humanoid figure. have script handles click move motion include:

public class mc : monobehaviour {      private float speed = 10;                   //speed of player     private vector3 targetposition;             //location of mouseclick; move     private bool ismoving;                      //check see if moving     animator anim;                              //animates humanoid piece      void start ()     {         targetposition = transform.position;        //current location         anim = getcomponent<animator>();            //gets animator controller attached piece         ismoving = false;                        }      void update ()     {         //if mouse clicked         if (input.getmousebutton (0)) {             //if piece selected; not moved yet              anim.setbool ("isselected", true);             settargetposition ();             //if still moving, move player             if (ismoving) {                 moveplayer ();             }         }     }     /// sets target position travel too.     void settargetposition()     {         plane plane = new plane(vector3.up, transform.position);         ray ray = camera.main.screenpointtoray(input.mouseposition);         float point = 0f;          if (plane.raycast (ray, out point)) {             targetposition = ray.getpoint (point);         }          //the humanoid piece being moved         ismoving = true;     }     /// <summary>     /// moves player in right direction , rotates them @ target position.     /// when player gets target position, stop them moving.     /// </summary>     void moveplayer()     {         transform.lookat(targetposition);          transform.position = vector3.movetowards( transform.position, targetposition, speed * time.deltatime);         anim.setbool ("iswalking", true);         //if @ target position, stop moving         if(transform.position == targetposition)             ismoving = false;     } 

** edit: adding picture of animation tree adding picture of animation tree


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -