This guide assumes you have already read/completed the previous tutorials.
File list
| File Link | Description |
|---|---|
| End Result | The end product of this tutorial for you to examine and compare. |
Device machines - what are they?
Now let's take a look at a new tag type we haven't used before - the .device_machine. These tags, at first glance, seem no different to animation .scenery objects. They have a few key difference though, the major one being dynamic (moving) physics models.
Step onto your newly spinning platform - you will notice that you do not spin with the platform. Walk into the platform from the side - you do not get pushed away by the pointy edges of the platform flying past. If you brush up against the platform enough, you will likely come to the correct conclusion that the physics model is not moving whatsoever. Even if we weighted the physics model to the Bone in blender, it would not animate in-engine. This is the main reason for using a .device_machine tag, as it does allow for all sorts of moving physics shenanigans.
Let's go over a couple of well-known device machine examples throughout the games (even if you didn't know that's what they are!) to gain a better understanding of their wide range of applications. In Halo 2's Cairo Station mission, you may remember the second time you venture into space, and you fight some flying elites on a large platform that moves up and down as part of the mac gun's firing mechanism. This entire area is not part of the level BSP, but is rather a large device machine. As it animates up and down, the physics do too. In Halo 3, remember the huge spinning wheel on Last Resort? That too is a device machine - it's blades push the player and other objects around as the wheel animates, indicating that it has dynamic physics! Most, if not all elevators in H2+ are also device machines for reasons that should now be obvious.
Creating an elevator animation
In the following sections, we will be making our platform into a makeshift elevator! This requires creating a new animation of the platform changing height, so let's get back to work in Blender:
Out with the old, in with the new
- We need to remove the current spinning animation from the platform. First, in the
Timelinewindow, set the current frame to frame1. - In the
Outlinerwindow, expand theArmatureobject if it isn't already. You should see animation data calledAnimation. Expand this too. Finally, you should now see an animation calledArmature Action. Select it, then right-click and chooseDelete. - Open
Windows Explorerand navigate to your platform's animations data folder, e.g."H3EK\data\objects\scenery\custom_platform\animations". Cut theany idle.JMMfile and paste it somewhere of your choice for safe keeping. We will not be using it for the time being.
Creating a new animation
- Select the armature object, and enter into
Pose Mode. - In the
3D Viewport, press I and insert aLocationkeyframe on frame 1. - In the
Timelinewindow, set the currently active frame to80. - Next, press G, Z, 200 to move the bone 200 meters upwards (the Z axis).
- Press I and insert another
Locationkeyframe.
That's it! This is a very simple animation, test it out with the play button in the Timeline window. The platform simply rises to 200m over 80 frames, then resets.
Device machine elevator animations do not need to be reversed in Blender. The Blam! engine is able to handle reversing the animation automatically, which saves us some work.
Re-parenting the physics model
In order for the physics model to follow the animation, we must change it's parenting:
- Select the
$platform_physicsobject in theOutlinerview. Then ctrl-click theBonebone. - Hover over the
3D Viewport, and press Ctrl + P to open the parenting menu. ChooseBone Relative.
You can double-check you did it correctly by playing the animation - the physics should now move seamlessly with the render model.
Exporting a device machine animation
Device machines have a built-in value called position ranging from 0 to 1, that determines how far through its animation it is. For example an elevator device machine with a current position of 0 would be at the rest/start position. A current position of 1 means that it is at its end position. 0.5 would mean it is at exactly the halfway point in its travel from point A to B. This position value can be directly controlled by both in-game buttons (another tag type, .device_control), or by game scripting, allowing for controlled management of a device machine's behaviour.
The animation for a device machine is a .JMO type. It is not a base type (.JMA, .JMM) because more complicated device machines can use multiple overlay animations at the same time to achieve complex behaviors. We will not be covering that in this guide - simply take away that device machines use .JMO for their position animation. As with our any idle animation earlier, the name we give the exported .JMO file does matter, as it determines how tool sets up the animation graph tag. To be used as the position animation, we simply need to export the animation as device position.JMO:
- Back in Blender, click
File->Exportand chooseHalo Jointed Model Animation (JMA). - In the export menu, make sure the
Game Versionis set toHalo 3 MCC, and theextensiontoJMO. Leave all other settings default. - Set the name of the file at the bottom to
device position, and export to theanimationsfolder.
How the export should be set up.
Importing the device machine animation
This section will be almost identical to importing the any idle.JMM animation from the previous tutorial. As written in that section, tool will remove any missing animations from the .model_animation_graph tag. We have moved the any idle.JMM file elsewhere - this means that after re-running the model-animations command, we will only have the new device position animation in the animation graph. If you already feel comfortable or fancy a challenge, try importing the animation on your own! Otherwise, follow these steps:
- Open up
CMDin yourH3EKfolder. - Type
tool model-animations "path\to\your\scenery", wherepath\to\your\sceneryis the tags-relative path to your scenery's data folder. For example if you have been following along exactly, this will be"objects\scenery\custom_platform".
You should now see the following output from tool.exe output after running the "model-animations" command.tool, informing us that the device position.JMO animation has been imported with no errors: 
As per the previous tutorial, if you open the The device position animation location in the mode and state graph..model_animation_graph tag in Guerilla and scroll down to the Mode-n-State Graph block, you should now see the device position animation has automatically been put into the Overlays group. 
Creating the device machine tag
Just like with the .scenery and .crate version of this custom object, we need to create a new top-level tag - the .device_machine tag.
- Open Guerilla. Press Ctrl + N to open the new tag dialog, and choose
device_machine. - Use Ctrl + S to open the save tag dialog, and save it into the platform's root folder (
"H3EK\tags\objects\scenery\custom_platform") ascustom_platform.device_machine. - Set the
bounding radiusto 3. - Click the
...next to themodelentry, and choose thecustom_platform.modeltag. - Scroll down to the
$$$ DEVICE $$$section near the bottom of the tag. Set theposition transition timeto5. This is the time our device should take to transition from a position of0to1or vice versa, in seconds. This means that once started, our elevator will take 5 seconds to reach the top. Adjust to your liking if you wish. - Set the
position acceleration timeto0.4. This is the time it takes the device to reach "full speed", and the time it takes to slow down from "full speed" to rest, in seconds. A value of 0 means it instantly accelerates from rest to full moving speed.0.4means it will take 0.4 seconds to accelerate up to max speed, and 0.4 seconds to accelerate down to rest at the top. It is usually a good idea to set a value here for elevators, to avoid clunky instant starts and stops. - Set the
typetoplatform. There are three options here:- Door - door types utilise the
automatic activation radiusto open when the player gets near. It uses thedoor open timeto determine how long to wait before closing once the player has left this radius. - Platform - these types are used for elevators, or other moving platforms such as gondolas. They do not activate automatically, and so require the use of a
.device_controlor scripting to function. - Gear - gear types simply play their animation on an infinite loop. The huge spinning wheel on Last Resort is a good example of this.
- Door - door types utilise the
- Tick the
elevatorflag.
Placing the elevator
It's time to see our elevator device machine in action! Open Sapien on a map of your choice:
- In the
Hierarchy View, selectScenario->Objects->Devices->Machines. - Click
Edit Types. ClickAdd, navigate to the custom platform folder, and choose thecustom_platform.device_machinetag. - Click
Done, thenOk. - With the
Machinesfolder still selected in theHierarchy View, right click in the3D Viewto place a new device machine object. In theProperties Palette, change thetypeto the custom platform. Give it the namemy_elevator. Move it around so that the platform is just above the floor.
Controlling the elevator with scripting
If you are not familiar with HaloScript, this may seem like a daunting task. However, it is as simple as typing a single line into Sapien's console. The HaloScript function we want is (device_set_position <device> <real>). The two parameters are as follows:
device- the name of a specific device machine placed on the map, e.g.my_elevator.real- a float, otherwise known as a decimal, between0and1. This controls thepositionvalue of the device I mentioned earlier. By setting this to1we cause the elevator to move up to the top, and if we set it back to0it will move back down to the ground.
Therefore, the command that we want to type into the console to make the elevator move upwards is (device_set_position "my_elevator" 1):
- Open the console in Sapien. The exact key depends on your keyboard's region - it is usually Tilde ` (beneath Escape), or the apostrophe (') key.
- Type or paste the line
(device_set_position "my_elevator" 1)into the console, and press Enter
You should now see the elevator rise into the sky! If successful, use Chief is having a whale of a time.(device_set_position "my_elevator" 0) in the console to bring the elevator back down to its starting position. Try standing on top of the elevator and then using the command - the physics model will carry you up with the animating render model! If you want to get to grips with the position value, try other decimal values such as 0.5 etc. 
Controlling the elevator with a button
The alternative method of controlling a device machine is via the use of a .device_control tag. These usually take the form of button panels, with a prompt similar to Hold E to open the gate when you get near. Device controls and machines can be linked through the use of device groups, which allows one to control the position of the other remotely. It is very easy to set up. We will not be covering how to make your own device control in this tutorial, instead we shall make use of one of the many pre-existing controls found in Halo 3. If you happen to be testing your elevator on the map Last Resort (Zanzibar), you can skip steps 1 through 3 as the control is already present in the map.
- In the
Hierarchy View, selectScenario->Objects->Devices->Controls. - Click
Edit Types. ClickAdd. Navigate to"H3EK\tags\objects\levels\multi\zanzibar\gate_control", and add thehouse_gate_control.device_control - Click
Done, thenOk. - With the
Controlsfolder still selected in theHierarchy View, place down a new control. - In the
Properties Palette, set the type tohouse_gate_control. Move the control to anywhere you like. - Click the
Device Groupsfolder in theHierarchy View, just belowMachines,ControlsandTerminals. - Click
New Instance. Select the new instance on the right side of the window. - In the
Properties Palette, change thenameto something recognisable. I will useelevator_group. Leave everything else default. - Click the
Machinesfolder, and select your elevator. In theProperties Palettescroll down to find thePosition Groupdrop-down, and select the device group name you just added, e.g. `elevator_group. - Select the
Controlsfolder in theHierarchy View, and assign thePosition Groupin the exact same way on the control you just placed down.
Now run over to the control and hold the interact button (E). The elevator will now start to move! Interact with the control again, and you will cause the elevator to return. You can do this an unlimited number of times. Interacting with the button causing the elevator state to switch.
That's all for this tutorial! Now you know how to animate two types of tags, we will be looking at adding a collision model in the next tutorial, so that you can shoot the platform and have the projectiles collide with it. The next section is currently under construction. If you'd like, you can review your progress so far on the home page.
Acknowledgements
Thanks to the following individuals for their research or contributions to this topic:
- Krevil (Info about JMO usage)
- PepperMan (Writing this guide)