Creating Doors


Tutorial Info


Tutorial
1 – Introduction
This tutorial will show you the basics of keyframes, animations, and FSMs, and have you make a working door with them. If you have previous experience in editing levels, you may already know what a keyframes is, but chances are you hadn’t heard of FSMs (Finite State Machines) until MaxEd came out. Before I tell you how to use these things, I’m going to explain them all.

2 – Keyframes
Keyframes are required to have any sort of level animation in MaxEd. They provide the beginning and end position for animations, while MaxEd then handles the in-betweens. You can create multiple keyframes for a single mesh, and then create dozens of different animations from just those keyframes.

3 – Animations
Animations are the easiest part to understand. You provide the beginning keyframe for the animation, as well as the end keyframe, then provide a length of time for the animation to occur over, and you have your animation. Animations are plentiful, whether they are doors opening, cars moving, or even a wall tipping over after an explosion.

4 - Messages (FSMs)
This is the term that has sort of spread over the entire messaging system of MaxEd. In order for an animation to begin, a message must be sent to the mesh, telling it to begin a certain animation. Messages provide the eye-candy for Max. They are how you start up particle systems for the effect of a cigarette in an ashtray, or the molten metal pouring out of a large drum. They also control camera cinematics, enemy AI, and even can control points like when to go into the graphic novel. They are the metaphorical blood that runs through Max Payne.

5 – Readying Your Door
I’ll assume you already have built a working map, and that you already have done everything needed short of building your door. First, make your door mesh where you want it. Make sure it is relatively thin, since most doors are only an inch or two thick at most. Now group your door to your world (F5 ctrl-e) and then select the door. Rename your door to ‘Mydoor’. Now in order for a mesh to be animated, it must be made dynamic, or moveable. In order to make a mesh dynamic, go into Transform mode, select your mesh, and press ‘d’. Answer yes to the question, and then answer ‘yes’ again. We also need to edit some of the options of the door in order to make it so Max doesn’t walk through it and etc. RMB on your door in the hierarchy list (upper-left corner of MaxEd) and choose ‘edit’. You want to make sure that it is set for dynamic collisions, bullet collisions, as well as pointlights affect. Once you do that, you door is ready to hold keyframes.

6 – Adding Keyframes
By making your door dynamic, you’ve already added your first keyframe. In order to add more, in Transform mode, select your door and press Tab. This will bring up a new window. First we want to rename the current keyframe as ‘closed’, this way we can reference it easier when setting up the animations. Now you want to add a new keyframe, so click ‘add’. Rename this new keyframe as ‘open’, then select your new keyframe and click ‘goto’. Now we need to rotate your door into the position you want to be considered as ‘open’. Before you rotate your door, though, you need to set a correct pivot for it. To do this go into grid mode (F12). Move the grid around until the center of it (the white-yellow-red lines) is where you want your door’s pivot to be. Go back to transform mode and select your door. Middle click and go into ‘mesh manipulation’ and choose ‘set pivot’, or just press ‘p’. Answer yes to the question and you have now set your pivot. You now need to set up the rotation preferences so it will rotate around your pivot point correctly. This is just a matter of press ‘W’ and then ‘A’ while in transform mode. This turns off ‘world axis rotate’, and turns on ‘pivot rotate’. Now make sure you’re in transform mode and rotate your door to how you want it to look when open. To rotate your door, hold your LMB, and then press 1/2/3 to rotate around X, Y and Z respectively. If you’re having problems rotating well, try moving your view around and try again. Once you’re done, go back into the keyframe editor (tab) and switch between the ‘open’ and ‘closed’ keyframe to make sure you’re satisfied. Now to make your animations.

7 – Adding Animations
You’ve got everything now set to add your animations. Goto Transform mode, select your door, and then press shift-Tab. This will bring up the animations dialogue. We’re going to make 3 animations, one for the door opening, one for the door closing, and a third that acts as a timer for the door to stay open for a second or two before shutting. Choose ‘add’, and have the start keyframe as ‘closed’, and the end keyframe as ‘open’ and click ‘ok’. Rename this animation to ‘open’. Add another, but have it start with ‘open’ and end with ‘closed’. Rename this animation to ‘close’. Now to add your timer animation, have both the start and end keyframe be ‘open’. It will ask you if you’re sure, and choose ‘yes’. Rename this animation to ‘stop’. You now have you animations, but you may want to change how long it takes to animate them. To change the length of an animation, select which one you want to alter, and press ‘length’, then enter the number of seconds you want the animation to take. To preview an animation, double-click on it. Now for adding your messages.

8 – Adding Messages (FSMs)
For an entire list of possible messages to use, check the readme that comes with Max-FX. To create messages attached to your door, make sure you’re in transform mode and select your door, then press ‘4’. This brings up the FSM for your door. We don’t want to add any states for the door, we just want to edit the messages, so click ‘messages’. A large dialogue box comes up with several tabs up top, and 3 sections. The first thing we want to edit is the Animation(open) tab, so click it. The three sections for animation(open) refer to when to execute the different messages. The top section, leaving 1st keyframe, happens immediately after the animation begins. The middle section, returning to 1st keyframe, happens whenever the animation is forced to invert, I’ll explain this more later. The bottom section, reaching 2nd keyframe, executes after the animation is complete. This is where our ‘stop’ animation comes in. After our door fully opens, we want it to stand still for a while, so we’ll add a message into the bottom section. Click ‘add’ and enter “this->do_animate(stop);”. This message tells your door to run the ‘stop’ animation you created. Now we want to edit the Animation(stop) tab, so click it. We want our ‘close’ animation to run after the door has opened and stopped, so we’ll add a message into the bottom section. Click ‘add’ and enter “this->do_animate(close);”. Now what if Max gets in the way of the door? We want the door to bounce back, and not get in the way, so click on the Do_MovedToInvalidPosition tab. Since we want the door to bounce back the instant it hits an obstacle, we want to add a message into the top section. Click ‘add’ and enter “this->Do_invertanimation();”. This forces the animation to play in reverse, and it is why we have the middle section for ‘returning to the 1st keyframe’. Say the door was closing, but is now having to swing back open from hitting Max, well we now need to add another message into the Animation(close) tab for it, so click it. Since the door is returning to the 1st keyframe, we want to add a message to the middle section. Click ‘add’ and enter “this->do_animate(stop);”. This will make our door do the stop animation again, as well as run the Animation(stop) messages again. You’ve now added nearly all your messages you need, but now we need to place a trigger for Max to actually use our door with.

9 – Enter the Trigger
Okay, a trigger is just another entity, but it needs to be placed where you want Max to have to use or run into to open your door. Once you’ve placed it, goto transform mode and group it to your room. Then press ‘4’ to open the FSM for your trigger. We want to edit the messages again, and now go to the ‘T_activate’ tab. This will execute the messages whenever the trigger is triggered. The sections for a trigger are labeled differently, but we’re only needing the top section, so click ‘add’ for it and enter “parent::Mydoor->do_animate(open);”. This statement tells your door to start opening. Now what if someone uses the trigger again? Well, the door will restart the animation from the beginning, so we need to disable our trigger once it is started. Add another message to the top section, and enter “this->t_enable(false);”. Now our door is practically ready. But now that we’ve disabled the trigger, we have to have the door reenable it once it closes again, so go back to your door and enter the FSM (4), then enter the messages. Since we want the trigger to be enabled whenever it closes, goto the Animation(close) tab, and add to the bottom section. Enter “parent::action_button_trigger_00->T_enable(true);”. One last message and your door is set to go. Goto the Animation(open) tab and add the same message as before to the middle section. Now if the door gets blocked while opening and recluses, it’ll still reenable your trigger. Your door is now ready to go.

10 – Conclusion
As you’ve noticed, making a simple door is a bit complicated at first, but once you begin to understand FSMs better, as well as learn how to use the transform better, it becomes quite a quick process with little problem. It is also easy to note that an one-way elevator can be made in nearly the same process, but instead of having an open and close keyframe, make an up and down keyframe. Once you think you understand FSMs, keyframes and animations enough, challenge yourself to check into how ‘states’ work. Well good luck with all your future mapping.