# raycast vehicle physics problem

This topic is 664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi people, I am now attempting to implement the ol' famous raycast vehicle physics. Based on several readings, particulary:

It works fine most of the time, as long as I satisfy these constraint:

1. the raycast have to be of similar length (the suspension+wheel radius) cannot differ from one another.
2. the suspension properties must be uniform (the spring coefficient(k) and damping coefficient(c)) cannot differ from one another.

Here's how I do the vehicle physics:

• for each wheel, each frame:
1. shoot a ray from the wheel suspension start position (in absolute frame) towards the absolute ray direction. Usually this is down (0, -1, 0) in local frame.
2. from the raycast detection routine, I got several useful information (the "time of impact" of the ray hits [0..1], the ray hit position (where the ray hits), the hit normal (the normal of the ray hit position).
3. then I calculate the suspension force (Ignoring the side slip friction and forward/brake force atm, focusing on the "hovering" first). the suspension force is then applied at the chassis @ suspension "start" position, and the opposite force is applied to "ground" @ rayhitpos. The force direction is parallel to the suspension direction (ray direction).

As I said, as long as the rays are uniform (similar length, spring coeff and damping coeff), it will works fine. Thing is, I'm trying to simulate a dune buggy, where the back suspension would have longer travel distance, also the back wheels are bigger in diameter than the front ones. Now that means I have to Make the back "ray wheels" have longer suspension travel and bigger radius, resulting in non uniform suspension length and spring properties. Also, the buggy suspension is not uniform. The back suspension is directed a bit backward, and the front suspension is directed a bit forward (this is called "caster angle", usually configured like that to smoothen up the ride). Now because of this, the vehicle would gain forward speed most of the time, because the net force applied would cause the chassis to move forward a bit.

I am thinking of instead of applying the suspension force along the suspension travel direction, perhaps it would be better to apply the force along the ray hit normal. This would cause the chassis to "float" along the ground just fine, since all the force are acting along the ground normal ("up" usually), so no lateral force would emerge. But is it the right thing? how did the vehicle physics in GTA 2 Vice City was implemented? Because one of the vehicle there (the "harley" bike) exactly configured like this (the front wheel's suspension is slanted @ 45 degree, not totally "down"), and the bike would ride just fine.

Here's an image that depicts the problem:

in the non-working case, the vehicle would move to the left, this is without side friction or forward/brake force (it shouldn't, right?). the red line is the ground, the blue is the ray, the black box is the chassis, the black arrow is the ground normal (rayhitNormal), and the brownish arrow is the suspension force, which is applied at the "raystart" (which is the end of the blue line inside the chassis)

##### Share on other sites

this is a problem in "Mechanics: Dynamics".   you can lookup how to solve it for real in any decent mechanics textbook such as Hibbeler:

https://www.amazon.com/Engineering-Mechanics-Dynamics-Russell-Hibbeler/dp/0133915387/ref=pd_sbs_14_t_2?_encoding=UTF8&psc=1&refRID=6JJNZ41Z0754SMH6HNGJ

nothing beats real physics!

##### Share on other sites

Ah, finally the problem was solved. I simply apply the "suspension force" along the normal direction of collision. This works well enough for my purpose. Thanks pal.

##### Share on other sites

Ah, finally the problem was solved. I simply apply the "suspension force" along the normal direction of collision. This works well enough for my purpose. Thanks pal.

That would be the black arrow in your drawings, right?

##### Share on other sites

Ah, finally the problem was solved. I simply apply the "suspension force" along the normal direction of collision. This works well enough for my purpose. Thanks pal.

That would be the black arrow in your drawings, right?

Yes sir. I apply the force along the black arrow (normal of ray hit)

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633701
• Total Posts
3013443
×