- Home /
Stop Animation then reverse after collision
public void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "Interactable")
{
GetComponent<Animator>().SetBool("Idle", false);
GetComponent<Animator>().SetBool("Run", false);
GetComponent<Animator>().SetBool("regularAttack", true);
GetComponent<Animator>().SetFloat("Speed", -0.2f);
}
}
i'm trying to stop the animation "regularAttack" and play it backwards when colliding with "Interactable"
but is not working. Any Help would be awesome!!!
Answer by haruna9x · Mar 07, 2019 at 02:05 PM
I see you seem to be on the right track. See if you missed something:
Inside the Animator window, add a parameter of type float named "My Speed Mult".
Select the state containing the animation and turn on the Parameter. Select the parameter "My Speed Mult". This allows you to multiply the animation segment speed by the value of the parameter.
Change the "My Speed Mult" parameter value inside your script. If you need to reverse the animation, set it to a negative value. You need to keep in mind that it is executing a multiplication with Speed value of State.
Your answer
Follow this Question
Related Questions
Trying to reverse planetary gravity 1 Answer
Reverse GUILayout 1 Answer
How to loop an animation in reverse? 0 Answers
360 degree for addforce 1 Answer
Reversing Door Animation 1 Answer