Arcade car physics

Started by
23 comments, last by bmarci 5 years, 4 months ago

That's looking really great!!  You should definitely start a project page/blog here(it's all available on gamedev.net), it's a great way to get some more feedback and have a central location to keep your updates if nothing else. ;)  Just click on Blogs or Projects from the home page and you should get the option to start a new blog or project respectively.  A project page is just general information about your game/project, and a blog can be used to post updates about a project or anything on your mind really.  Can't wait to see what you make!

Advertisement

Thanks a lot for your encouragement @Septopus B|

I'll do as you said then, just need some time to prepare it :)

In the meantime, I managed to get the sideways force implemented properly (got back to dot product and its amazing uses), fixed the suspensions which always cause issues, added friction (separated from the sideways force: it seems like you could go with one that does both, but if you really want the amazing drift mechanics like Crash Team Racing, you'll have to implement it properly. Thanks to that I could also lower the friction to a realistic minimum, and at the same time the force of the engine, so that the slopes provide a realistic slow down), made a more realistic downforce which allows to take loops reliably, put back the vehicle on its feet, computed the vehicle speed (in the flat surface plane, that is not counting the gravity component), added a dropout condition when taking sharp bumps and a few small things.

Now I'll have to actually modelize a track. Then add a way to know if you're going forward, if you achieve laps as expected, and handle collisions with other players. That's probably when I'll start to model my car not as a soap box but with spheres or similar :)

WOW..  That's a lot of meantime!! :D  Once you're ready to start blogging I hope you write up some how-to's on this project for people to follow.  As you well know, these mechanics can be fairly frustrating to get working

Keep it up!!  Can't wait to do some laps.

Thanks! :x

I just went ahead and did it right away ;)

It's really just a start and I'll take care of it, including much more laid-back explanations about the algorithmic contents :)

BTW I did something very similar with what they did in space dust racing.
Here is the result
https://twitter.com/ongamex92/status/981449356820742144 https://twitter.com/ongamex92/status/981449356820742144

 

Really nice! :) looks like you have very heavy cars ;) and you implemented the gizmos and all!

Btw what does your collider look like? Is it a capsule, two spheres, a box, or something custom? (compound)

On 11/19/2018 at 6:08 AM, Brunni said:

Really nice! :) looks like you have very heavy cars ;) and you implemented the gizmos and all!

Btw what does your collider look like? Is it a capsule, two spheres, a box, or something custom? (compound)

Thanks a lot!
Well for that particular car it is just a convex mesh, similar to a box, but cut where the front window is (I'm at work currently so I cant show it to you).
Wheels do not have any collision representation, they are just ray casts. (I'm using Bullet Physics if anyone is intrested).

FWIW we have a "realistic" simulation used for driver training, traffic simulation (and making a futuristic racing game :D) and it uses a lot of the same techniques. Wheels are just ray-casts and a whole bunch of "springs". Instead of a single spring, the suspension can be multiple springs all connected together, plus the tire and rim are stiff springs too. In complex suspensions the two sides of the car might be linked somehow. The most complex difference is how friction is calculated -- for an arcade feel, you can just make up some friction based on forwards + sideways sliding and tweak the numbers until it feels fun. For a simulation feel, you try to copy Pacejka's magic friction :)

In our game, we also make the collision-shape for the car much higher off the ground than the visuals (e.g. if the car's floor is 10cm off the ground and the roof 1m off the ground, then the physics shape might have a floor that's 50cm off the ground). This does mean that when "bottoming out", the visuals can intersect with the ground somewhat... but it avoids an annoying gameplay moment where the vehicle-vs-ground collision causes unpredictable results for the player. It often feels more natural to just let the springs resolve the situation rather than a rigid-body collision.

On 11/20/2018 at 6:55 PM, ongamex92 said:

Thanks a lot!
Well for that particular car it is just a convex mesh, similar to a box, but cut where the front window is (I'm at work currently so I cant show it to you).
Wheels do not have any collision representation, they are just ray casts. (I'm using Bullet Physics if anyone is intrested).

OK got it, thanks :)

I switched back to a box for now because the elongated capsule would allow the car to (attempt) climbing on walls ? (since I made the capsule to be above the ground so that I use the raycast from suspensions to rest on the ground, the spherical "nose" with a good force applied forward from below the car could allow the physics to rotate it on its back and start climbing. I think I'll switch to a "home" like (triangle for the nose + box).

Another thing I struggled with was to get the physics engine to react ""kind of"" natural in this kind of situations:

CarGame-v5.mp4

I played Mario Kart on my 3DS the other night… man how good their engine is :D (it's clear that they don't use a physics engine, and the more I go, the more I see that it's completely pointless, I just have to learn the maths behind the "body.ApplyForceAtPosition" and how a box rotates based on an imbalance of forces at different points in the body)

Btw I've posted an article on my blog. I intend to continue as long as it feels useful, focusing on things that the video in my first post doesn't really explain in detail :)

10 hours ago, Brunni said:

I just have to learn the maths behind the "body.ApplyForceAtPosition" and how a box rotates based on an imbalance of forces at different points in the body

This is exactly what I did in my simulation :)

This is a quite good starting point: https://gafferongames.com/post/physics_in_3d/

This topic is closed to new replies.

Advertisement