- Home /
Animation not working
My sprinting animation isnt working , there are no errors but its not budging ... im using the standard fps controller with some edits to the script ... i want to play the sprint animation only if im sprinting
function Update ()
{
if(isSprinting == true)
{
sprintAnime.Play(sprintString);
}
else
{
sprintAnime.Stop(sprintString);
}
}
Is this script on the correct object?
Can you add a debug in Update() to make sure its being called?
Answer by Nexum1 · Sep 12, 2013 at 09:36 AM
If it is in the update, I believe it is constantly trying to play the animation (Every frame) resulting it in starting over each frame..
Try to use something like
if(!animation.IsPlaying(sprintString))
{
sprintAnime.Play(sprintString);
}
To make sure it's not already playing...
i am a noob at scripting ... where do i place this..?
In update.. Ins$$anonymous$$d of what you have, try this:
function Update ()
{
if(isSprinting == true)
{
if(!animation.IsPlaying(sprintString))
{
sprintAnime.Play(sprintString);
}
}
else
{
if(animation.IsPlaying(sprintString))
{
sprintAnime.Stop(sprintString);
}
}
}
Oh quick thing , i $$anonymous$$NOW it will work , but i havnt "declared" the string , so the string doesnt mean anything ... i need to make the stringAnime , the sprintAnime .. any help?
Your answer
Follow this Question
Related Questions
Character Animation Wont Play 2 Answers
My animation is not importing into Unity. 0 Answers
FindGameObjectsWithTag not working 1 Answer
Application.Quit not working?! 5 Answers
Walking script not working need help 1 Answer