Help: Exposed vehicle suspension rig (Blender to Unity)

Hi,
I’ve got a nice exposed vehicle chassis for my monster truck.
I move the wheels around on their suspension springs in code in Unity (but I guess the process would be analogous in any game engine);
So I know where the wheels should be, and I need to move the wheel-hubs and suspension rods around to match.

I’ve got this working nicely in Blender right now (I think!). If I grab a bone in pose mode and move it, everything looks good:

So what I’ve got here are three vertex groups: one for the “root” of the chassis, one for the rear part, and one for the front part.
The front bone-pair controls the front vertex group, and each have a “Damped Track” constraint so they always look at each other, the rear bone-pair works in the same way:

It works fine in Blender, but I find that Unity doesn’t import the damped track constraint, and doesn’t handle a pair of bones being attached to the axle’s vertex group properly:

So it’s kindof setting the rear axle at a height that’s the average of the two wheelpoints, and not rotating it at all.

Is there some way to do this in Blender that will export/import properly into Unity (or, I believe the process is similar in Unreal)?
I’m a C# programmer, and could do this in C# in Unity pretty easily:) But I think actual artists can do this stuff in Blender, so I’d like to learn how (I’ve plans for a more ambitious rig on a different model:).
My experience with Blender is pretty limited, just slicing meshes up and this attempt at rigging. So, I’m not even sure what I’m supposed to be Googling here, I can see a lot of examples of rigging people & hands & stuff with their bones all connected, I’m not sure if that’s applicable here or not. I’ve had a bit of a look around, but it feels like a lot of the rigging advice I’m seeing will work in Blender or whatever, but not import into a game engine.
Hope I’m putting this in the right sub-forum!
Thanks for reading:)
:cookie:biscuits​:sparkles:

Constraints aren’t imported. They are specific to any code to evaluate them. The code for damped tracks exists in Blender, not in Unity. But you can program this into Unity pretty easily. (Do axis angle rotation of the bone, in an axis equal to the cross product of the bone and the desired vector, of an amount equal to the arccos of the normalized bone and normalized desired vector.)

Not sure what you mean. Bones aren’t attached to vertex groups, unless you’ve given them specific constraints (which you haven’t mentioned in regards to this, and which, again, won’t be imported into unity or any other game engine.) Instead, meshes are attached to bones via vertex groups with shared names.

In general, artists do this stuff in Blender by baking their animations. But baked animations aren’t dynamic, don’t respond to variables in the game engine. If you need animations to respond to stuff in the game engine, you have to set those relationships up in the game engine itself.

Ah, sorry, I was using the wrong words: I think I’m doing what you describe.
If I remember correctly, first I made a vertex group for the rear axle.
Then I put a bone on the left of the rear axle, and armature-deform-parented it to an empty group (which created a new vertex group with the same name as the bone); then I assigned the rear axle’s vertices to that group:


Then I repeated for the bone on the right of the rear axle (then the Damped Track bone constraints to make the bones look at each other).

So if I’m understanding correctly, if my model had no rear axle, I could bake an up-down animation for each wheel on each spring, as those animations don’t interact with each other; but because the axle has to track the state of both wheels, I can’t bake that.
That’s fine, I’m confident doing this in Unity instead, C# & maths are my thing:)
Thanks for the reply!

Not quite. If your up-down state is a function only of animation frame, you can bake that. If it’s a function of the game position of your model and the distance to the ground, then that’s dynamic, and you can’t bake that.

If you’re having trouble baking the animation, I would wonder from your description if you have a dependency loop. The right way to have two bones damped track each other is not to have them directly damped tracking each other, but for one of the bones to have an unconstrained parent, and the other bone can then damped track that. You can check for dependency loops by opening a console window and reading the warnings.

1 Like

Hi,
Thanks again for the reply.
The up-down state of each wheel hub can vary by, say, +/- 0.5m and can be anywhere within that range at any time.
E.g.,
Rear-left Z+.5, Rear-right Z=0:
image
Rear-left Z+.5, Rear-right Z+.5
image
Rear-left Z-.5 Rear-right Z+.5
image
So, from my very limited understanding of animation, I could bake, e.g., just the rear-left wheel hub going from -0.5 to +0.5, and then in Unity get it to move between frames of that animation; but that would only work for the left wheel hub? Because if I did the same for the right wheel-hub, I wouldn’t be able to set target frames for both hubs and have Unity figure out what to do with the fixed axle, since it’s controlled by both hubs? I haven’t looked at baking animation yet. I do indeed have a dependency cycle in my current setup:)

I feel like what’s going to be easiest for me is have a single bone per axle, rather than bones per wheel-hub, and set height and orientation of it in code.
It seems like this is all really easy for independent suspension, this beam/ fixed axle thing I’m doing is awkward, apparently:)

If your wheels are intended to respond to game terrain, you can’t really take advantage of baked animations. The angle of each wheel depends on the position of both wheels. Because the wheels are also rotating, you’re probably not rotating in a fixed local axis. Yes, you should just be setting up your damped tracks in Unity. Like I said, it’s relatively basic in terms of 3D math. (It would, strictly speaking, be possible to set this up as baked animations, or rather, spherical lerping between two poses, with wheels separated from axle, but I suspect that would be a silly way to handle the problem. You’d just be trading one run-time math problem for a different run-time math problem.)

1 Like