- Home /
[Unsolved] Playing animation backwords [Unsolved]
Hello!
I try to make my player play the "walk" animation backwords when the user presses "S". I tried this, but it only plays the animation once. Any help??
function Update () {
if(Input.GetKeyDown(KeyCode.S))
{
animation["walk"].speed = -1;
animation["walk"].time = animation["walk"].length;
}
if(Input.GetKey(KeyCode.S))
{
animation.Play("walk");
}
}
Answer by DricoJD · Jun 17, 2013 at 12:00 PM
An Animation can be scripted backward, it would be a function of a mere connection of strings and variables. My best bet and simple way of getting around this is either make a seperate animation or go to the animation setting and set it to ping pong. If this does not work this way you can always make a script to change animation settings via a script; comment if you want me to write it for you. Also if this way I suggested work can you thumbs up :)
hand.animation["walk"].speed = -1;
hand.animation["walk"].time = -1;
hand.animation["walk"].length;
hand.animation.Play("walk");
thumbs up
get rid of all your script contents that is presented in your question - and just paste this inside the as a new function as so:
function update()
{
hand.animation["walk"].speed = -1;
hand.animation["walk"].time = -1;
hand.animation["walk"].length;
hand.animation.Play("walk");
thumbs up
}
Please thumbs up as it keeps me running on my oil!
It doesn't work. What's "hand.animation["walk"].length;" doing alone??? Anyways, I want it to play when the player walks back, not always!!
P.s. Calm down with the "thumbs up"!!!! It doesn't work like youtube! :) P.s. I don't think hand. is neccesary.....