Trigger animation, play once & disappear

Hi

I'm new to Unity and I'm making a game so that when the user enters a room they trigger off an animation which is blocking their exit.

an animation to play, when the player enters a room. For them to watch it once. Then for the animation to disappear. Which allows the person to carry on going through the rest of the game.

How would I go about doing this?

Any help would be most welcome

Kitty

everything you have told me in a comment (to do with what your current unity project has and your progression in this task)could do with being included in your question. If you dont inform people of what you have and just ask how to do something that takes a few steps (plus saying im new to unity) it looks like you havnt done anything. If you have got somewhere include it in your post.Specify your question and you will get an indepth answer. Check updated post

–

I know this is an very old post, but I am trying to figure out a similar thing. I need an animation to disappear after its done doing its animation and I can't figure it out for the life of me!!! any luck on this???

–

1 Answer

1

use an empty game object in your scene. add a box collider (or whatever shape best fits the area the player enters) then check "is trigger" in its inspector properties. Then you have to make an animation using the animation editor. Select your door then open the animation editor then edit it as you see fit. Once the door has its animation applied as a component you can then add a script to the trigger area that states when a player enters this trigger area, start the animation.

in order to do this you will need to know how to do these things :-

creating trigger zones : fairly easy. Empty game object, add collider, check is trigger.

making animations in unity : will involve looking at the documentation provided by unity as to how to use the animation editor. once you understand how to use it this task is very easy.

scripting events in unity : this involves learning how to script. There are many ways to achieve the same thing in scripting, it all depends on how you want it to appear, feel and work. For playing animations via a trigger area on a single game object though is not to difficult or varied.

So everything is fairly straight forward, its the basics of unity which you need to learn before asking questions like this again. Try some of the unity demo projets to understand how to set-up this sort of thing and then once you know how you can go about scripting it for yourself. It's not too hard once you know how but then again what is? I guess running through a brick wall is pretty hard even if you know how to do it....

EDIT

So i cant know for sure as you havn't provided me with the info yet but im assuming you have a door object with an imported animation. If it only has one animation then this will be relatively easy. If it has several....lets just assume it has one for now. So what you need is to make a trigger zone like I said previously. Then make a script attached to the trigger zone which sends a message to the door object to play its animation.

I understand that newbies have to start somewhere but considering my colleagues and I managed to learn Unity from scratch using only the documentation provided by Unity and by deconstructing standard scripts and community wiki scripts I feel its possible for absolutly anyone to do so. Especially since none of us were programmers 3 months ago and now we have made a networked game which we are hoping will land us a job at rockstar games.

You need to stop telling yourself that you are limited by yourself and start thinking of it as you are limitless as it's just you and your imagination, no-one to hold you back. You can make anything in games, and the number one lesson to know is that games are predominatly visual based, you can get away with loads of different things as long as the game looks right. For instance with our networked game we tried to remove players after they had died but that caused all sorts of problems (long list) so instead we had them "teleport" to miles away from the playing area and switch off the camera. that way it appears to have been removed. Long story short it doesnt have to be exactly right it just has to appear right for the player of the game.