Welcome to helloserve
This is my personal project and hobbyist website where I chronicle some of the things I do on my computer, in my garage, or otherwise. I've got game development stuff, petrol head stuff, general software development stuff and other bits and bobs. Check out the project or blog sections.
- This blog post was made using Blender 2.83.3 and Unreal Engine 4.26.2
If you haven’t read it, check out part 1 for what we’re importing today.
Now that we have our sliding door animation sorted, we need to bring it into the game engine to make use of it. In Blender, the hierarchy currently shows the armature as the main node of this mechanism, and the two door geometries are children of it.
The biggest trick that you will always forget when you do this is to rename that main armature node in the hierarchy to root. Unreal Engine looks for that node name specifically and will generate errors when you import the animation with that name being anything else. Side note: This dependency to that name is not a documented thing afaik. I also just read it on a random forum post while I was pulling out my hair trying to get this working.
Next, select root and everything else in that mechanism hierarchy, go to File->Export and select to export .FBX files. There are a bunch of settings here. Check for the Object Types of the thing you’re exporting, the geometry smoothing, the axis settings and the animation checkboxes.
When you’ve got it set up, optionally click the + icon at the top and give it a name so that you can select these settings as a preset in the future.
Side note: You can also select not to export the armature and animations by deselecting those Object Types but leaving all the other settings the same, and setting a preset for static mesh exports.
This will create an FBX file at your chosen location. Switch to Unreal Engine and select to import this file into the content browser, again at your desired location. The import dialog should be set up to include skeletal mesh and animation too. Set the animation range manually, otherwise you’ll end up with a lot of dead time (unless you’ve culled it already in Blender).
This should create four items: a mesh asset, an animation asset, a physics asset and a skeleton. Open the animation asset, and you should see the animation play with the doors sliding over each other.
Back to the content browser, and right-click to create a new actor blueprint. This will be a blueprint for the entire elevator. In the blueprint, add a skeletal mesh component, and choose the elevator doors mesh asset as the mesh. They won’t be moving. To fix this, make sure to set the animation that the skeletal mesh should use, to the animation asset that was created when you imported. Now the doors will animate repeatedly.
Save this blueprint and load up a map if you don’t have one already. I used the TopDown template. Drag the elevator blueprint into the level and place it near your starting location. When you play the level, you’ll see the elevator doors animating in a loop. This is a good sign, but we want to control when it opens and closes obviously.
Back to the elevator blueprint and on the event graph, drag the elevator doors skeletal mesh component into the editor near to the Event Begin Play. From that node, drag a pin and Set Play Rate to zero. This value controls how fast the animation plays. Connect the execution pins, save and check it out in the level now. The doors remain closed. Great!
Again back to the elevator blueprint, and now create a function called “OpenDoors” in this blueprint, and drag the skeletal mesh component into the editor to create a node. From this node, drag out to Set Play Rate again but this time to 1.0, and drag again to call the Play function. Connect up the execution pins.
Save this blueprint and then back on the map, add a trigger box somewhere close to the door. Create an Actor Begin Overlap event on the trigger box. This will drop you into the level blueprint. Drag the elevator instance into the blueprint also, and drag a pin from it to call it’s new Open Door function. Connect the execution pins.
Now when you play your level, and walk into the trigger box, the doors should open. That’s cool!
Now let’s go back to the elevator blueprint. Create another function called CloseDoor. Drag the skeletal mesh into the editor again, and drag from it’s pin and add a Set Play Rate node, and set it to -1.0. Then drag from the skeletal mesh node again and call the Play function. Connect the execution pins. Now the animation will play in reverse.
Back in your level, add the Actor End Overlap event on the same trigger box, and in the level blueprint call the new Close Door function on the elevator.
When you now play your level and enter the trigger box area, the doors will open, and when you leave the trigger box area, the doors will close.
You can of course now play around by adding state variables to add a delay to the doors once they’re open to automatically close again, and to prevent the animation from being interrupted for example, so that it doesn’t start closing while it’s still opening.
This illustrates how the elevator can be commanded by something else when to open and close the door. You can actually include the trigger box in the elevator blueprint so that each instance operates completely autonomously and then you don’t have to have open and close functions. This is great for like Star Trek type doors. Having those functions public though allows for other elements in your level to command the elevator when to open or close, for instance when completing some objective or pressing an elevator button.
Keen readers might have noticed that the doors don’t actually block navigation. You have to assign the physics asset that was created at import to the skeletal mesh in the elevator blueprint. It’s also a good idea to apply a box envelope to the doors instead of the default capsules. More information on this can be found here.
And that’s it. Export additional static mesh assets for the sides, floor and ceiling of the elevator and include it in the blueprint.
Rigging up elevator or sliding doors with an armature (bones)
- This blog post was made using Blender 2.83.3
- Top Tip: In general [Alt+...] menus in Blender are "negative" or "remove" menus, and [Ctrl+...] menus are "additive or "create" menus.
I’m building an elevator, and I want to make the doors open and close on player interaction. You can code it, or you can animate it. I wanted to animate it.
And in fact I did code it in Unreal Engine Blueprints. It’s not hard, but it does require quite a bit of keeping state and timeline nodes and branches. But there’s a whole animation system in Unreal (and Unity and others) to make use of. Just use that? Cool, but you first have to actually provide the keyframes. This is my first time rigging anything in Blender.
I’m not unfamiliar with bones (or armatures). I used it long ago in 3DSMax. So really I just had to learn the hotkeys and menu options. Also, I couldn’t find a post or video specifically about sliding doors which doesn’t use empties with constraints and parenting. And I didn’t want to use shape keys since I find it limiting and arbitrarily hard to control precise movement due to mesh deformation interpolation. Not to mention your UV side effects. Thus I decided to write this post.
First up though, I watched a character rigging video. Rigging a door is mostly the same thing, but not as complicated with symmetry and all that stuff. It’s a good foundation since you’ll be rigging characters at some point anyway. The two things to take-away for this post: Decoupling bones and parenting geometry to a bone.
Most elevator doors are split in two, one slides over the other because of limited space on the side. This means you should have two bones, and they have to be decoupled because one of them has to move independently in the local space from the other.
Go ahead and place the first bone (Add -> Armature). I place it on the right edge of the right door, and rotate and scale it to lie flat along the Y-axis along the width of the door. Drop into Edit Mode and then [E]xtrude to create the second bone, constrained to the Y-axis and also for the width of the second door. If your armature is obscured by the geometry, you can select In Front to have it visible in any viewport shading mode.
With the second bone selected (yellow highlight), press [Alt+P] to bring up the Clear Parent menu and Disconnect it.
Test this action by switching into Pose Mode, [G]rabbing this bone and moving it around. Only it should move. Select the first bone, [G]rab it and move it. The second bone should also move with it. Undo these movements.
The next step is to bind your geometry to the respective bones. Don’t use automatic weights! Back out to Object Mode. Select the first door, and the armature.
Once you’ve got the armature selected, you can go into Pose Mode. From there, make sure only the first bone is selected. It should highlight blue, while the door is the dark orange highlight. Now [Ctrl+P] to show the Set Parent To menu, and select Bone only.
While you’re in Pose Mode, [G]rab that first bone and move it. With it should move that door you just parented, and the other bone. Nothing else should move with it.
When that checks out, back out to Object Mode again and repeat the process for the other door and other bone.
This should have you all setup with your door mechanism structured correctly. Back out to Object Mode and deselect everything. Select just the armature and now you’re ready to go into Pose Mode and keyframe the movement of your bones. Select the first bone, [I]insert a keyframe for LocRot (location & rotation) at frame 0. Move to frame 100 and [G]rab that first bone and slide it to the side. [I]insert another keyframe here. You’ll see that the second bone and door slide with it.
Now move back to frame 0, select the second bone and [I]insert a keyframe for it for LocRot too. Go to frame 100 again and [G]rab the second bone and slide it even further so that the second door slides over the first door. [I]insert another keyframe for the second door here.
Use the animation play/pause buttons to see your work. Switch to the Animation view and use the dope sheet or graph view to tweak the ease-in or ease-out or move the keyframes and such until you’re happy with the result.
Next episode: Import it to Unreal Engine and make a blueprint.
Reason #3463 I dislike taking my car to a workshop:— Henk Roux (@helloserve) January 4, 2020
They overtighten EVERYTHING.
I tweeted that because I had to use the power bar to get the top two bolts loose that attaches the air conditioning pump to its bracket. It was frustrating because there’s very limited space between the sub-frame, rail, engine block and the various pipes to work, and because it’s why I was again busy fixing the car. Workshop staff around here just do not understand what torque limits are.
So, previously I wrote a short blog about that time I took the car to a very well renowned workshop around here to sort out the air conditioning. They ran into some issues with the pump leaking, but promptly sorted it out. Until about a month ago, when the whole thing came loose. I started experiencing belt slippage when I steered at slow speeds, and it progressed so I decided to park the car. And in fact, the entire air conditioning assembly was hanging from one bolt, the belt, and the flexible bits of pipe by this time. As explained previously, the air conditioning pump attaches to a bracket, which is attached to the block. There is a bolt in the front (which I had trouble with before) that goes through to the oil pump, and another one on the side of the block. These two hold the bracket in place. The one on the side was missing. I never heard it fall out while driving (it’s happened before with another bolt, I know what that sounds like!), so I was a bit surprised. Was it completely missing?
This was how far the front bolt had come undone when I inspected.
I started disassembly, and found that the stud was there but the head was gone. It had been sheared off in the workshop. I’m sure, since that’s the last time there was work done in that area. Thank ye old gods that front bolt didn’t wreck my oil pump as it slowly became undone over the last months of driving the car (recall that it stood in my garage for 5 months while I was dealing with the water pump et al.). How, by god, how tight must it have been to have held on for that long by itself? I have the official torque specifications document from 1989. The oil-pump-to-block bolts (one of which is this), is a mere 26 N.m. That’s screwdriver hand-tight!
After a lot of faffing and trying to figure out if there’s enough space to fit a drill, I discovered a second, threaded, hole in the block which lines up with a second hole in the bracket. It’s tucked in behind the pump itself and becomes inaccessible when the pump is attached to the bracket. There wasn’t a bolt there before, but it gave me a way out. I could get the bracket secured to the block without necessarily having to extract the stud from the sheared bolt. So I started to loosen the pump from the bracket, and of course I had to use the power bar on all four bolts on the pump. What is up with these workshop mechanics? Do they all turn green and rage when the customers aren’t around? As a matter of interest, these bolts’ specification is even less! Only 22 N.m. 🤷♂️
When everything was loose and sort-of moved out of the way I did attempt to drill out the stud. I got a right-angle Dremel fitting and everything, but the tool rotates too fast and I only managed a few millimetres deep before the metal tempered - not enough for the extraction bit to grab on and be effective. In the end we (some friends joined as usual!) just put the bracket back using the second hole, made sure everything is tight without drinking the special koolaid and ripping everything to pieces, and wrapped up. It’s not off the jack-stands yet, and I need to get a new battery, but it started up and we could inspect the belt alignment. So all is good, and time to get it out of the garage now for this new year.
Anyway, I’m really fucking annoyed by this, because it’s the same thing every time the car is at a workshop. Ford messed up (and lost?) the fittings for my front brakes. Some bloke at another workshop blew the soft-top’s window out with a power hose in an attempt to wash it. TWT had to send one of my wheels off for repair when they scored it trying to get a nut loose that their guy had tightened down just a few minutes prior. 🤷♂️ I only have bad workshop experiences on this car, and it’s why I do all the work myself as much as possible.
I have a ton of respect for John and Jason at CoolCo. They are very knowledgeable and have exceptional customer service. But it’s clear their workshop staff didn’t look up any torque settings. These are professionals that did apprenticeships and trained to do this. I mean, there isn’t a single bolt on the outside of this block that torques higher than 50N.m, with the exception of the timing gear bolt. It’s not a specialized engine, in fact it’s one of Mazda’s more typical engines: a stock standard B6 that was in the 323, Familia/Astina and other models. How in the hell do they get it so wrong?