- Home /
Enable animation C#
So what is happening is I am making a script to enable an animation here is the script:
using UnityEngine;
using System.Collections;
public class Poke : MonoBehaviour
{
public Animation poke;
public float fireRate = 0.5F;
private float nextFire = 0.0F;
void Update() {
if (Input.GetButton("Fire1"))
{
GetComponent<Animation>().Play("poke");
}
}
}
and here is an image of the inspector
so I can't add the animation to the box I realized this is because I'm using an animator instead of animation and I don't know how to change this or how to make it so the animator is what is enabled. How do I fix this so the animation is enabled when I click and so I can put my animation in the box.
Your answer
Follow this Question
Related Questions
Can I change animation key frame property in script? 1 Answer
Unity 2d, Need help with Player Sliding when Swiping Down 0 Answers
Animator and Scripting problems. Help !! 1 Answer
How to create animations that can be edited with scripts in runtime? 1 Answer
Why is my Character staying in Air Idle rather than Grounded Idle? 0 Answers