Constraint Steering

Hey, I’m making a vehicle and need it to be able to steer. Right now, I’m just using angular velocity to get it to steer for testing purposes, but now I want the front wheels to actually turn. I’ve been experimenting with different designs, none of which work. This is the closest I’ve gotten:

https://gyazo.com/2339322d47c750c1fd85476518bbc8fb

There, there’s a top part connected to a lower part with a prismatic constraint and a spring (but that’s not what I’m worried about, the suspension system is already fine). That lower part is then connected to another part (which I’ll call the axle part) with a hingeconstraint to allow the axle part to rotate on the Y axis (to steer the wheel). The axle part is the one connected to the wheel with another motor hingeconstraint. So the idea is that the hingeconstraint will be set to servo to allow the axle part to rotate, thus steering the wheel. However, as you can see in the gif above, it glitches out when it reaches it’s target angle. At the very end of the gif you can see me setting the angular velocity to 0, at which point it stops glitching and rests at the target angle.

Just out of curiosity, I set the hingeconstraint to motor to see if it still glitched out, and it works perfectly fine in motor configuration. It just glitches like that in servo mode. If anyone can recommend a new steering system/explain why the current servo glitches out like that, thanks.

I now have it working marginally better than before, and this is what it looks like on the actual vehicle:
https://gyazo.com/ee5df371fd384e0ad7cf7a5bb93ecd53

As you can see, when I turn the wheels while stationary, there’s still a little bit of bounce, but not as much as before. It continues to glitch out as soon as I start moving the vehicle, as you can see at the end of the gif. The AngularSpeed of each hinge is 5, and the max torque is inf. Player has network ownership of the entire vehicle.

I might be wrong, so don’t take my word for it but I’m pretty sure that angular velocity won’t work because it’s a force vector and even though it is technically giving torque, it’s not staying still because it’s not a stable property. What I think is happening is that it’s trying so hard to get to the target angle that it overshoots its target, then attempts to compensate with equivalent force and then overshoots again and then just loops like that. I think it might work better if you use a stable property, such as the motor hinge type like you mentioned or perhaps turn down the ServoMaxTorque? Again, I could be wrong but from what I know about hinge constraints I think it could work better.

1 Like

Instead of actually having a motor that turns the wheels, you can instead try and actually change the orientation of the attachment. You can try and do this with TweenService as this is perfect for smoothly tweening the Vector3 of the orientation property. However make sure to set the Network Ownership to the driver to make sure all the physics based parts are connected to that client to prevent latency and lag. Hope this helps!

Here is a demonstration I made, you can then tween the orientation property to have it move, depending on how you place the attachment, along the plane axis (the green axis in the picture) to have it rotated.
a
b

3 Likes

I’ll try this as well, I think I fixed it by lowering the density of the wheel. I figured out that my rig worked perfectly if there wasn’t a wheel attached or if a small block was attached in place of a wheel, so lowering the density worked. Your solution seems easier to do, so I’ll experiment around and see what works best. Thanks

Edit: Your solution worked just fine without me needing to edit the entire constraint system, just a tiny part of the script. So I’ve marked your answer as solution.

2 Likes