- Home /
Blender Animation loops when it should not
Hi,
Pretty new to unity, and have come across my first snag that I have not been able to find a solution to, hopefully someone here will be able to help :)
I have made a basic door in blender, which I have imported into unity. The door has a 70 frame animation, first 30 frames is opening, last 30 frames is closing.
I have created an animator, and an animator controller, and have broken the animation into 3 clips, idle, open and close.
I have created a script and assigned it to the door model.
bool PlayerInCollider;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
if (PlayerInCollider) {
if(Input.GetKey(KeyCode.E))
{
Debug.Log ("Triggered");
anim.SetTrigger("Open");
}
}
}
void OnTriggerEnter(Collider obj) {
Debug.Log (obj.transform.tag);
if (obj.transform.tag == "Player")
{
PlayerInCollider = true;
}
}
So, when I walk up to the door and press e, the door open animation plays, but it keeps looping, I have nchecked the loop time box, and am really baffled as to why this is happening?
My animator settings are below, any help would be appreciated!
alt text
Answer by carrollh · Feb 06, 2015 at 04:16 PM
Add a transition back to DoorIdle that works once the DoorOpen animation finishes.
Hi, thanks for the comment. That does work, although I was under the impression that a trigger caused the animation to play once? Anywho, I added a new clip for idleopen, and I have got it to work now. $$anonymous$$any Thanks
Well, I think the way a Trigger works is that it sets a boolean to true, then sets it back to false as soon as the animation finishes. But your state machine takes priority and there wasn't a way for it to get back to idle. So it had to stay in DoorOpen. I think the transition back to idle could be done with a boolean (if you had one) or with the animation time out. Or with a new animation like you did.
Glad you got it working.
Your answer
Follow this Question
Related Questions
model isnt animating in 3rd person 1 Answer
Problematic blur with skeletal animation 1 Answer
Animation from a Blender model not looping 1 Answer
Can I make animations snap to a frame? 1 Answer
Blender Animation Looping Delay Problem 2 Answers