Page 1 of 1

Suggestions On Wheel Steering Implementation

Posted: Mon Oct 17, 2011 5:58 am
by Socram
So I've hit a brick wall in my game that I can't seem to get past. The wheel "component" for my block based vehicle consists of a caster type wheel, made up of two RevoluteJoint constraints, as depicted below.
Image

I was able to get this working just fine, however my issue now is when I tried to implement steering controls. *Technically* I need two separate types of wheels, rear non-steering wheels (which I currently have implemented by replacing the purple axis RevoluteJoint with a Weld), and steering wheels which I want to work similarly to the vehicle wheels on the demo vehicle. When the player steers left the wheel should gradually rotate over to a maximum angle, and on removal of input it should gradually rotate back to center. And of course the opposite direction for turning right.

I've tried different implementations, based of the code in the demo, based off what I can come up with, and can't seem to find a solution that is stable, let alone works. Any ideas?

Re: Suggestions On Wheel Steering Implementation

Posted: Mon Oct 17, 2011 7:59 pm
by Norbo
There happens to be a new test demo in the development version called SuspensionCarDemo which does something very similar:
SuspensionCarDemo.cs
(9.48 KiB) Downloaded 355 times
The above example also introduces suspension to smooth out bumps. It doesn't have to have suspension, though. The ReverseTrikeDemo shows a similar vehicle without suspension:
ReverseTrikeDemo.cs
(10.53 KiB) Downloaded 330 times
By using a swivel hinge joint, it avoids the need for an intermediate entity and two revolute joints. This makes things faster and more robust. There's an example floating around on the forum somewhere that uses two revolute joints and two entities to control the same number of degrees of freedom, and it does work fine- but it is harder to solve and requires more tuning.

Another interesting thing you may notice: if these sorts of physical, relatively-high-mass wheels are spinning very quickly, they will seem to resist the car's attempts to steer. The effect is more pronounced if MotionSettings.ConserveAngularMomentum is enabled. It's a good idea to keep things at reasonable speeds.

Re: Suggestions On Wheel Steering Implementation

Posted: Mon Oct 17, 2011 10:25 pm
by Socram
Yeah that does look a lot easier to manage, but I I would like to get the visual of the middle component revolving on it's axis. I suppose I could just parent the model's Y rotation to that of the wheel and just set up the wheel using the SwivelHinge. Thanks.