Question by
blackshtormx · Mar 27, 2016 at 08:10 PM ·
c#animationspeedbackwards
animation play backwards (speed -1)
so speed = 1.0f works fine when i want to walk forwards, but when i walk backwards speed = -1.0f is not working, and i don't know why, here is my code:
void Update() {
if (Input.GetKey("s"))
{
anim = GetComponent<Animation>();
anim.Play();
foreach (AnimationState state in anim)
{
anim.Play();
state.speed = -1.0F;
}
}
if (Input.GetKey("w")) {
anim = GetComponent<Animation>();
anim.Play();
foreach (AnimationState state in anim)
{
state.speed = 1.0F;
}
}
if (Input.GetKeyUp("w") || Input.GetKeyUp("s"))
{
anim = GetComponent<Animation>();
anim.Play();
foreach (AnimationState state in anim)
{
state.speed = 0.0F;
}
}
Comment