I have an Animation Controller
(I’ll refer to it as Player_AnimController)
and 4 Animations (Player_Hurt, Player_Idle, Player_Jump and Player_Walk).
I have every Single Animation already set up, but what Lines of C# for Unity Code do I need to type in order to play Animations?
You can look in your animation controller and set boolean parameters for when the animations should play, from there turn the Boolean values true or false based on circumstances in your code attached to the player. That is how I have done it, but I am a beginner so there might be some other better or more common way(?) I’m not sure. Sorry if I sound a big confused because in truth I am but this here code worked for me!
public class freyawindwalk : MonoBehaviour {
public SpriteRenderer SR;
public Animator Animtor;
public bool cold = false;
public AnimationClip FreyaWindWalk;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other) {
if (other.CompareTag ("Freya")) {
Debug.Log ("FreyaEnter");
cold = true;
Animtor.Play("FreyaWindWalk");
}
}
}