- Home /
How do i make my Raycast Car not slip at all?
hey,
im trying to make a car with a rigidbody and rays for each wheel.
the car gets vertical forces that are equal to a spring and a damper in real life and they work pretty good so far.
forward movement is pretty simple for now but it works too. the problem is the sideways force. i cant figure out how to add the right force to make the wheels not slip at all.
thats why im asking you to help me. i appreciate every bit of help.
this is what i use to calculate the force that works against the x motion. (dont mind the if's)
xForce = localHitVel.x;
if (xForce < 0)
{
body.AddForceAtPosition(transform.right * (xForce - xForceAdd), transform.position, ForceMode.VelocityChange);
}
if (xForce > 0)
{
body.AddForceAtPosition(transform.right * (xForce + xForceAdd), transform.position, ForceMode.VelocityChange);
}
EDIT:
Fixed it... i applied the "Magic Formula" by Pajecka
Hi!
I wonder about your implementation. Did you write a custom suspension script with forces or you're relying on fixed colliders for "suspension" so the wheels don't fall through the road mesh?
How does it work for steering?
Could you perhaps share how you managed to apply Pacejka forces?
I am really struggling to find a good source of info on it, and every project I've seen so far has done it in a very convoluted way to "simulate" a car, whereas I rather would like a simple implementation that's more like an arcade racer that behaves semi-realistically.
I understand the Pacejka formula itself. I also understand suspension physics, I have made a car that has realistic suspension as well. It even has weight transfer when I hit the acceleration/brakes.
But steering/cornering and sideways force baffle me, I can't seem to wrap my head around it. Considering you managed to find out how to apply it it would be really helpful if you could share the basics :)
Thanks!
Your answer
Follow this Question
Related Questions
Raycast align with ground normal 2 Answers
Raycast Car-Vehicle Physics 1 Answer
Creating a magnetic vehicle (like F-Zero) 1 Answer