0
\$\begingroup\$

i've imported a door from blender to unity. it has two animations, open and close.

i've put an animator and script on it, and everything works fine. it opens and closes when i press x using a box collider, just peachy.

the problem is that the door starts out opened when I run the game. I need it to start out closed. i have it set to closed as the default state, thinking that would work, but what happens is w hen you start the game, it just closes immediately, and then you can open it and close it after that. how would I go about setting it to closed when running the game?

\$\endgroup\$
1
\$\begingroup\$

so from what i can tell is that unity assigns the default position by alphabetical order in your animations. so if you have an animation named close, and an animation named open, it will start at the first frame of the first animation by alphabetical order. being that the animation to close the door starts in the open position, the door will be open by default.

i fixed this by just adding a 1 before open and a 2 before closed.

add an empty default state in your animator that has no motion and has a transition towards open, which then transitions between open and closed, but no transition back to the default state, and it works fine.

if anyone else has a solution that doesn't involve renaming your animations, that would be nice.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.