Door openes on start of the scene

Had that bug with closing door on start too, so i made 1 more anim with single frame(door is closed) and made it default state as i want that door to be closed on start. And then made transition on bool change from AnyState to open without transitioning to self - seems to work fine.

4 Likes

Nice one thanks!

Can you exaplain in more detail what the transitions are please?

I always get my door closing on game startup even if I place an intermediate empty state. Because the transition is triggered on IsOpen = false, and when the game starts the value is false, so that transition is triggered.

Update: I fixed it. You dont need to create any “DoorClosed” or “static closed door” animation for this to work.

You can just create an empty state, name it however you like, and add this transition to DoorOpen:


This is how the animator looks:

Hope this helps :smiley:

4 Likes

Thank you, this approach worked very well.

For me it didn’t work exactly like shown in the screen shot. To make the door I set to be open at the start to not perform a visible animation, I had to set the Transition Offset to 1, so it would enter the DoorOpen state at the end of the animation.

Also, I set the Animator’s parameter within Awake():

private static readonly int IS_OPEN = Animator.StringToHash("IsOpen");

private void Awake()
{
  animator = GetComponent<Animator>();
  animator.SetBool(IS_OPEN, isOpen);
}

And I needed a transition from the initial state to both door states, or otherwise it might happen that the first opening of a door occurs without proper animation…

Privacy & Terms