Why wont my animation work?
Hey I'm new in Unity and I was trying to create a scene where I could close or open a certain door using the animator component. Im fairly new to the c# language and as far as I can tell my code is alright, but the door wont react when I press the left/right mouse button. The animation si suppossed to react depending on which button I press, left for open, right for close.
Nothing would work out, I dont know what I missed or if the error is in the code.
Code:
using UnityEngine; using System.Collections;
public class anims : MonoBehaviour { public Animator anim; // Use this for initialization void Start () { print (" TEST START"); anim = GetComponent (); }
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Fire1")) {
anim.SetBool ("open", true);
anim.SetBool ("close", false);
}
else if (Input.GetButtonDown("Fire2")) {
anim.SetBool ("close", true);
anim.SetBool ("open", false);
}
}
}
Your answer
Follow this Question
Related Questions
Having problems with making a Navmesh Agent stop and play an attack animation 0 Answers
Animator transition not working on parameter 0 Answers
Unassigned Reference Exception 0 Answers
2D Animation disables Player Controller Script 1 Answer
How do I not trigger animation during play state of the triggered animation. 1 Answer