• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Drifting Car physics without built in physics?

rytan451

Member
Represent the car's velocity using a vector (or using two variables). Also, represent the position and orientation of the wheels in memory.

When the car is moving, check the car's angular velocity. Use that to derive the velocity of the wheel from the car's angular velocity; add that to the car's velocity. Decompose the resulting vector into two vectors: first, along the wheel's rolling direction, and second, perpendicular to the first. Calculate the friction of both. The one along the wheel's direction gets less friction, and the one perpendicular to the first vector gets more friction. Repeat for all four wheels. Calculate the change in angular momentum when applying the friction forces. Change the angular velocity based off this value. Finally, modify the car's velocity based on its mass and the friction forces.

You can identify how much "drift" is happening by checking the magnitude of the movement of the wheels perpendicular to their direction. Using this information, you might wish to add tire tracks under each wheel.

Using this description, it should be possible to Google up the math, and you should be able to convert the math into code. (I hope you're good at algebra!)
 

NightFrost

Member
Also, if you know hot to use 2.3 structs, you can use them to present vectors and throw the maths stuff into methods.
 
Top