View Full Version : Door states
rtqbsm
03-25-2004, 04:20 PM
In my level I have a locker door. What I want to do with it is to have it so that I can open, it and when it is open I can close it again, but all this states stuff is giving me a headache. Can someone tell me how or point me in the direction of some tutorials?
theHunted
03-26-2004, 05:22 AM
that should be done easily. first thing you need to do is to set up the 2 animations. create one for the door opening (moving from keyframe1 to kf2) and one for the door closing (kf2 -> kf1). call them 'anim_open' and 'anim_close'. now give the door 2 states. call one 'closed' and the other one 'opened'. let's assume the locker-door is closed at the beginning of the level, you should create the 'closed' state first, so it becomes the default state. if you did it the other way around just right click on the 'closed' state and select 'make default'. now add a custom event handler to the door, and call it 'tr'. create a trigger that should open the locker (a use trigger would be best i guess), group it to the door, and call it 'trigger'. now in the trigger's on_activate tab add the line 'parent->FSM_Send(tr)'. go back to the fsm editor of the door, and switch to the custom event handler 'tr'. right below '%%%closed' add the lines
this->DO_Animate(anim_open);
trigger->T_Enable(false);
below %%%opened add
this->DO_Animate(anim_close);
trigger->T_Enable(false);
now switch to the anim_open tab in the editor, and add
this->FSM_Switch(opened);
trigger->T_Enable(true);
to the area below %%reaching 2nd keyframe.
last but not least switch to the anim_close tab in the editor, and add
this->FSM_Switch(closed);
trigger->T_Enable(true);
to the area below %%reaching 2nd keyframe.
i wrote this from the top of my head so i can't give you a guarantee if all names fit together 100% now. unless i made a mistake this should work however. you can extend from there and add sounds to the door animations etc...
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.