[SOLVED] Steering a rigid body car

Hi, I am working on a rigid body car. I managed to set up the driving but strugling with steering. In Blender, normaly the motor constraint works fine. I can set velocity and impulse even at high values with no problem. The problem is, when it comes to do the same thing for Armory 3D, there is no motor constraint. So I tried a few things and the most promising is the apply torque node but even I set torque oriantation correcly, it turns the whole car under constant torque, The solution should be changing angular velocity of rigid body like in the motor constraint but I can’t fiiigure out how to do it with “set RB velocity” setting proper angular velocity without affecting others. Any ideas?

Also please consider making “add RB constraints” node updatable on the go.

Hi and welcome to Armory,

A few things I’d like to suggest. A physics vehicle can be built with bullet physics constraints. But what might be a more stable and better approach is to use make a ray cast based vehicle with spring equation. Might sound complicated, but gets easier as it goes. One of the resources that could be used for this:

Now, to the issues that you are facing;

  1. Do you apply the torque to the wheels or to the vehicle body? If you apply it to the vehicle body, to I would expect the entire vehicle to turn. If not, then what type of constraints do you use?

  2. “set RB velocity” setting proper angular velocity without affecting others.

Hmm, for this, you could use the get RB velocity and connect it to the set velocity node input. So the current linear velocity will be constant and only the angular velocity would change. But I agree, it is a bit difficult working with this node. Perhaps it is better to separate the node into 2 or 3 dedicated nodes.

  1. “add RB constraints” node updatable on the go.

This might not be possible. From my knowledge, the physics engine Bullet physics does not allow for changing the constraints after they are added. But will look into it when I get some time.

1 Like

Thank you for this detailed answer.

1. > Do you apply the torque to the wheels or to the vehicle body?

I use generic spring for suspension and generic (pivot empty) driving. I think that is normal because the wheels are on the fron and I constantly apply torque on them which also effect the whole body

2. >  get RB velocity and connect it to the set velocity node

It was even hard for me to apply the torque on the right axes (relative to the body). The wheel is constantly rotating and I couldnt find a solution to set it’s velocity relative the body. Even I could do that I may not preserve the acceleration that I constantly give with torque (driving) at the same time

I tried to get the stearing angle and control the steering torque but I couldnt find it either. The steering might still be an issue for me even if I use raycasting.

3. > Bullet physics does not allow for changing the constraints

I’ve just checked and realize that it is also not possible in blender but realize removing it works and it might be handy at sometimes.

  1. Sorry, I did not understand the actual issue here. Is the steering of the wheels the issue or the forward/ backward torque applied to the wheels the issue? It would be better if you could also share the Blend file.

  2. I also did not understand why implementing a ray cast vehicle would be an issue here. What type of physics based vehicle you create depends on the type of game you are making. And bullet physics constraint solver is not exactly accurate enough for vehicle physics with multiple springs because of the mathematical solver that is used. And expecting a vehicle built using bullet physics constraints to work as you want it to might not be fulfilled. So, again, I suggest looking into ray cast vehicle.

  3. realize removing it works and it might be handy at sometimes.

You can remove the constraint by removing the constraint pivot object(usually an empty object between the two RB to be constrained):
Physics Constraint Node Documentation

car_test_barebone2.blend (1.4 MB)
The main problem is steering the front wheels while driving. Normali this is done by giving angular velocity on a spesific axis with motor constraint. This axis is normaly is the local Z axis of an empty parented to the body but I couldn’t manage to do it.

Hmm, I cannot agree to this. How could you set the steering of the wheel using just velocity? I mean, it can be better controlled by rotation on a specific axis. If you use velocities, you are required constantly to adjust this steering velocity so the front wheels don’t keep steering with a constant velocity.

Do you have some resources that use this type of steering you mentioned?

I also don’t understand what you add the vectors here instead of multiplying them:

1 Like

Well I can show you with this example:
motor constraint.blend (933.5 KB)

I also tried to rotate it on a spesific axis but 2 problems occured. The firist one is haven’t found a proper way to rotate it relative to the body. And the second one is it will be worse than setting velocity since it will stop the turning wheels.

I actually have no idea :sweat_smile: .

I think I will try to find the angle between Z axis of wheel and Y axis of body, change the torque accordingly, and see if it works.

  1. Okay, but once you steer the wheels to the left, how do you bring them back to the zero steering position?

  2. And since it is a constraint and if there are other forces acting on the wheel, for example due to the ground not being flat, how do you do it then?

This is not about Armory or any game engine for that matter. It is about the principles that you use to build your vehicle.

  1. You change the velocity according to the angle and velocity 0 acts as a angular constraint
  2. I didn’t understand the question but It doesnt effect other constarints. There is also a blender car rig addon called RBC that uses the same idea.

It is not like I blamed Armory, I just tried a principle that can already be used in blender and tried to apply it to Armory since they share the same bullet engine. Then I came across somethings I can’t figure out and asked if I am missing something or we can find some workarounds.

On the other hand I fixed my problem and it is at OK state now. The blend file is attached if anyone is interested. I used multiple math nodes because I couldn’t figure out how to use “acos” in math expression node. Used float interpolations and generic springs to damp steering. Also rigid body quality setting might be good.

Thank you for the help and interest.
car_test_barebone4.blend (1.4 MB)

1 Like