I want to add an attack animation to be used with the default third person controller script. Simply using animation.Play() does not work. If anyone has figured out how to do this I would greatly appreciate it!
1 Answer
1Create a sperate script to handle your attack animations. In that script, create a variable for the animator component of your character.
public Animator anim;
Then, you will need to get the component of your animator component.
void Start () {
anim = GetComponent < Animator > ();
}
Now you can play animations on the animator.
void Update () {
if (Input.GetKeyDown ("g")) {
anim.CrossFade ("Attack", 0.1f);
}
}
If you're trying to add this to the actual third person controller script--don't. Instead, make a separate script to handle animations. The animation should of course be on the gameobject, and then you should just be able to call it like so: animation.Play("attack"); 'attack' is of course the exact name of your attack animation. If that doesn't work, then there is some other issue.
– agamedesigner