- Home /
change position and play animation
I have this frog AI that should go to a certain location using waypoint and while changing its position my object should play its animation jump.
here's my code but its not working
function Update () { var frog = GameObject.Find("try"); if (frog.transform.position(0>1,0>1,0>1)) animation.CrossFade("jump");
else animation.CrossFade("idle"); }
yes its changing its position but its not playing its animation? please help
Answer by · Aug 30, 2010 at 10:26 AM
Your ifcheck is always true. What are you trying to check?
Also, you should put the 'frog' declaration in Awake(), so it's not looked up every frame.
function Awake () { var frog = GameObject.Find("try"); // Set it once here, so it doesn't search every frame }
function Update () { if (frog.transform.position(0+1,0+1,0+1)) // This will always be true - you are just setting the position animation.CrossFade("jump"); else animation.CrossFade("idle"); }
so should it be if(frog.transform.position(0>1,0>1,0>1)) animation.CrossFade("jump"); ??
No - I don't understand what you're trying to get it to do. At the moment you're changing its position and at the function just returns true. Perhaps edit your question and list out what you are actually trying to achieve. When you say 'waypoint', what do you mean?
Your answer
![](https://koobas.hobune.stream/wayback/20220613072336im_/https://answers.unity.com/themes/thub/images/avi.jpg)