You are browsing as a guest. Sign up (or log in) to start making projects!

Physics Based Car game

  • 2 Devlogs
  • 2 Total hours

The car controller for this game will purely be physics based i.e. every spring force, friction force engine force will be actual force and not just visually similar to real life but physically similar , the player will FEEL the car.

Open comments for this post

1h 12m 17s logged

A Physics Based Car Controller in Unity! (Tire friction simulated !!)

Devlog #2: Adding Friction to them Tires 🔥🔥

So this was a tough one. On the surface the theory is pretty simple, friciton force acts opposite to the direction of motion and its magnitude is friction coeffecient*Normal force on one tire.

that I implemented by calling each tires velocity , and taking its dot product with each tire’s RIGHT vector, so if the result is 1 –> rightways velocity, if its -1 –>leftways velocity and if its 0 then the car is moving straight.

I wrote the code for this and steering which just rotates the front two tires by a set amount. Felt pretty good and pressed play, and BOOM the car is spinning, the tires are spinning, MY HEAD WAS SPINNING.

The majiority of todays time was spent figuring out what was going wrong 😭 , Went through the Unity Docs, reddit and everything couldn’t find the bug.

I set the steering function to rotate the front tires in world space and not local space

welp that was the problem, Just One word!! Makes me think how important part even a small thing plays in a big system and That is my argument against nihillism lol!

Learned how to normalize vectors today and successfully debugged my code. Yup See ya’ll in the Next one!

0
0
3
Open comments for this post

56m 34s logged

A Physics Based Car Controller in Unity! (Suspension Physics added)

Devlog #1: Adding Suspension Physics Using Hooke’s Law.

In Cars each tyre has a set off supensions that absorbs shocks and damps it down so that its comfy inside, So it basically is a spring.

So to simulate that in Unity I used Hooke’s Law

that states : Force Exerted By spriing = Spring Constant(material property of spring) X Spring Compression Amount

When we do excert such a force for each tyre of the car, it creates a dynamic spring that changes exerted force by the amount its being compressed VERY COOL.

###But if we leave it like that Its going to oscillate Up and down forever which would not be very realistic. 🥀

So to encounter That I incorporated a damping system which takes In the speed of a given tyre, takes its Dot product with the vector UP , which tells us how fast is the tyre moving up, and **Lower the amount of exerted force as it reaches closer and closer to 0 compression slowwly losing energy and stablizing **

All that was done by subtracting (tyres downward velocity X damping constant) from the Force equation!!

##Andd that wraps it up for today! See ya’ll tmrw!

0
0
3

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…