Skip to content

Rally Car

Rally Car

In this tutorial, we will create the wheels and chassi of a car in a semi-realistic fashion. It will have realistic suspension and limited to spinning along only one axis, but it won't be able to steer.

Up to date

Written for Ragdoll 2021.08.06 and above, but should still apply for 2021.06 and newer.

Estimated Time

  • 🕐 30 minutes

You will learn

  • ✔️ How to make geometry dynamic
  • ✔️ How to constrain two rigids
  • ✔️ How to make wheels with translate and rotate "limits"
  • ✔️ How to build a static environment

Where to find help

If you find or run into any issues with this tutorials, here's what you can do.


Motivation

Before we dive in, let's first consider why anyone would want to simulate a car in the first place. To answer this I invite you to take a gander at this clip here.

If we ignore that characters for a moment and look at just the car itself; there are a few things going on that would be both challenging and time consuming to animate by hand.

  1. Wheel suspension responding realistically to the ground
  2. Chassi responding realistically to the wheels
  3. Contact with and response to debree on the ground
  4. Wheels loosing grip due to on debree
  5. Matching the wheel rotation to contact with a non-flat ground

The subtle detail alone is enough to make a senior animator sweat, not to mention changes to the environment would require an almost complete redo of all of that work.


Setup

Let's start with some basic polygons.

image

One chassi, one wheel duplicated 3 times.


Chassi

Our chassi will be a simple polyCube.

Attribute Value
Width 3.0
Height 1.0
Depth 4.0

image


Wheel

Wheels will take the shape of a polyCylinder. We will later bevel it, for nice round edges.

Attribute Value
Height 0.7
Radius 1.0
Axis X
Axis Divisions 19

Important

Make sure to make the cylinder in the X axis, that is the axis our wheels will rotate about.

image


Assembly

Putting the pieces together.

  1. Move the chassi up by 2 units along Y
  2. Duplicate the wheels 4 times
  3. Parent the wheels to the chassi
  4. Position the wheel alongside the chassi

My values

For the wheels, I used Translate values X=2, Y=0 and Z=1.5

You should now have this. (Naming is optional)

image

image


Dynamics

Now it's time to apply physics to these objects!


Active Rigid

Select all 5 pieces, the chassi and wheels, and run the Active Rigid command from the Ragdoll menu.

makerigids

Your Outliner should now look like this

In your Outliner, you should now find a rRigid shape node for each wheel and chassi.

outlinerrigid

The rRigid node is where you will find attributes to control the physical material and behavior of the chassi and wheels, such as the Friction of the wheels against the ground and Mass of the chassi.


Parent Constraint

Next, select the chassi and Shift + Select one of the wheels to make move together with the chassi.

parentconstraint

Repeat this process for the 3 remaining wheels.

parentconstraint2

This will glue the wheels onto the chassi, and we will shortly "unlock" the axes we are interested in for suspension and roll.

Your Outliner should now look like this.

image

With the new constraints lying beside the rRigid.


Suspension - Free

The wheels are currently fixed onto the chassi, but what we really want is for the chassi to be softly attached to the wheels. To accomplish this, we are going to unlock one of the Translate Limits of the wheels, namely Translate Limit Y.

  1. Select all 4 wheels
  2. Enter a value of 0 for the Translate Limit Y attribute

What does 0 mean?

A value of 0 means disabled, the wheel will be free to move along this axis without disruption. Since the other axes are left at -1 that means it will only be able to move in a straight line. Like how you might expect suspension to work.

unlocky


Suspension - Soft

Now the wheels are free to move along the Y-axis of the chassi. But they are too free to move. What we want is for the chassi to bounce back, like a spring.

  1. Select all 4 wheels
  2. Set Guide Enabled to On
  3. Set Guide Strength to 0.3
  4. Set Translate Guide Damping to 200
  5. Set Rotate Guide Stiffness to 0
  6. Set Rotate Guide Damping to 0

guide

That's more like it. We aren't interested in having our guide affect rotation, not yet. So we only enable it for translation, such that it will try and keep the wheel where it started.

Tweaks

Control how "springy" you want the suspension with the Stiffness and Damping attributes.

In real life, "stiffness" is the thickness of the physical spring whereas "damping" is how much resistance there is to it. Like if the spring was made of stainless steel which has a low resistance, or made out of clay which has a very high resistance.

Caution

Take care not to leave too much room between the chassi and wheels. The constraints are made to simulate reality, and in reality there cannot be an empty space between two objects that are connected.

gapbetween


Environment

The wheels are currently unable to roll. To test this, let's put some ground under those wheels.


Set Initial State

Let's move the car to higher ground and set a new "initial state", meaning the position and rotation from which to start simulating.

  1. Move the car along Translate Y = 10.0
  2. Play

By playing, the initial state is automatically updated to wherever the car was at the time of playing.

initialstate

Alternatively

Rather than playing, you can also use the Set Initial State command founder under Ragdoll | Rigging | Set Initial State

image


New Ground

Make a new cube and place it under the car, with some tilt such that the car will naturally roll.

  1. Make a new cube
  2. Resize it to create a ramp
  3. Place it under the car

As we can see, the wheels are unable to rotate! Let's fix this.


Roll

The wheels cannot rotate because they are limited along every rotate axis.

  1. Select each wheel
  2. Set Rotate Limit X = 0, zero meaning "free to move"

Remember

  • A limit of -1 means "locked", it cannot change.
  • A limit of 0 means "free", it is unlimited
  • A limit greater than 0 means it can change within the specified range

See Limit States for details.


Finalise

We've got our car! From here you can tweak the shapes, tweak the stiffness and damping, add some more tracks, you name it!

You have learnt

  • ✔️ How to make geometry dynamic
  • ✔️ How to constrain two rigids
  • ✔️ How to make wheels with translate and rotate "limits"
  • ✔️ How to build a static environment


Engine

Now let's put some horsepower into those wheels.


Animation Constraint

To make the wheels spin, we'll apply an Animation Constraint.

  1. Select one of the rear wheels
  2. Run Animation Constraint

Animation Constraint

A special constraint used to transfer keyframes into the simulation. In this case, what we're looking for is to rotate each wheel along the X axis.

animconstraint


Rotation Only

Next, disable the Translation of the animation constraint, since the wheels are already held in place with the suspension we put in place earlier.

  1. Select both Animation Constraints via the Outliner
  2. Set Translate Guide Stiffness to 0
  3. Set Translate Guide Damping to 0

animconstraint2

Caution

Take care not to disable the Translation of the first Parent Constraint we made earlier.

The safest way to modify both Animation Constraints at the same time is by selecting them in the Outliner. If you instead select the wheels and modify them via the Shapes section, then Maya will kindly go ahead and modify both the Animation Constraint and the Parent Constraint.


Ready, Set, Animate!

Ok, great. We're all set to animate!

  1. Select both rear wheels
  2. Set some keys on Rotate X
  3. Watch it go

Caution

The faster you try and spin the wheels, at some point you may encounter this.

carfaster

That's because at some point your animation will be greater than 180 degrees away from where the simulation is, and the simulation cannot distinguish between an angle of 180 and -180.

By providing an exact angle in this way, we are able to reach specific positions with the car in a very reliable way, but do have to pay attention to special cases like these.

To solve this, you can increase the Stiffness of the Animation Constraint to effectively give the needed horsepower required to meet your animation requirements. If you need it to go even faster, you may also need to increase the Iterations and Substeps on the rScene, for helicopter-speeds or greater.


Accurate Roll

If you let the wheels spin slowly, you'll notice how the resolution isn't quite enough.

  1. Select the original wheel
  2. Set Subdivision Axis = 50 on the polyCylinder2 shape

That's more like it, but what about the other wheels? Because we duplicated them, they no longer retain the history of this polyCylinder node.

To solve this, let's replace the mesh used for collisions by the other wheels such that they all use this one wheel.

Important

Make sure the Maintain Offset is unchecked, since we want the local position of the wheel for each wheel.

image


Suspension Range

In a more realistic example, your vehicle model will have natural limits to how tall the suspension can be. For example in this truck example, there is a ceiling to the rear wheels.

image

We can let the suspension remain soft and springy until a certain point, by providing a range of allowed Y values. The range is given by a value of Translate Y Limit that is greater than 0, the amount being how many Maya units the wheel is allowed to move (typically centimeters).

Start Time

Keep in mind that any of the Limit attributes can only be changed on the start of your simulation. The start frame can be adjusted using the Start Time attribute on the rScene node.


Race Track

Let's use the Duplicate command to lay some more track.

In my case, I found that the suspension was too loose, so I increased the Guide Strength to 0.4.

  • 👉 You can also lower with the Friction on the ground, to allow for the chassi to slide on contact.
  • 👉 You can also experiment with the chassi Shape Extents to make a more narrow vehicle
  • 👉 You can also experiment with the Shape Offset to raise the chassie higher off the ground (like a monster truck!)

Combined with the engine, you can now make a proper race track!


Bevelled Wheels

The wheels are currently very sharp. Once you add more detail to your environment, you may find that a bevelled wheel behaves more predictably and doesn't get stuck on equally sharp corners.

Since all wheels use the same geometry as one of the polyCylinders, all we need to do is bevel one of them.


Homework

Here are some suggestions for how to take the results of this tutorial further.


Mecabricks

A fantastic resource with tons of mechanical contraptions, most if not all of which are ready to be turned into mechadolls and ragcars!

Speaking of ragcars, here's one Ragdoll-powered example using this excellent model by @Estevanpoa.

Which has an interesting mechanism for steering that was accurately recreated with Ragdoll rigids and constraints.

More Videos

Can't get enough, huh? :)


Robot Wars

Why not design a contender, and have yourself a little Robot War?

image


High-Resolution Model

Find any vehicle model and either parent the geometry directly to the chassi and wheels, or use Maya's Parent Constraint to keep things clean.


Steering

Given what you've learnt, how would you enable steering? How does it work on a real car?

Click to reveal a hint #1

Is there a part missing between the chassi and wheel?

Click to reveal a hint #2

The Ragcar from the Mecabricks section above has steering, how does that work?


Last update: 2021-08-27