How do I modify animation parameters from script (C#)
Okay I'm a beginner, and I am making a basic click-based attack system. I have made "Attack" and "Idle" animations in Unity 5, and I am trying to write a C# script that will tell Unity to transition from "Idle" to "Attack", then back to "Idle" when I click the left mouse button.
I have set up the transitions in the Animator window and created a bool parameter ("Slice") that must be true in order to invoke the transition, but I cannot figure out how to change this parameter from my script.
Here is what I have: public class Weapon : MonoBehaviour {
Animator ani;
void Start() { ani = GetComponent(); ani.enabled = true; // this starts the "Idle" animation }
void Update() {
bool attack = ani.GetBool("Slice"); //this bool defaults to false
if (Input.GetMouseButtonDown(0))
{
attack = true;
}
attack = false; // I tried removing this but it made no difference
Do I need to create a helper class?
Comment