Advertisement Jump to content
Brunni

Arcade car physics

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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 :)

Edited by Brunni

Share this post


Link to post
Share on other sites

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.

Edited by Septopus

Share this post


Link to post
Share on other sites

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 :)

Edited by Brunni

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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:

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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!