Jump to content
  • Advertisement
Sign in to follow this  
Bow_vernon

raycast vehicle physics problem

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

If you intended to correct an error in the post then please contact us.

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)

vehicle_raycast.png

Share this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 this post


Link to post
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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!