Turn-based vehicle physics

I’m currently working on a proof of concept for a turn-based car game. Each turn, you get to decide what you’ll do over the next second or so, whether it’s accelerate, turn, etc. I’m currently “pausing” the game by subclassing MonoBehaviour and having that toggle isKinematic on my rigidbody objects, which does a good job of freezing their movement. The vehicle physics are currently using a (modified) version of the AlternateVehiclePhysics package from the Unity car tutorial.

Here are my questions:

  • I’d like to have some way of predicting the player’s location at the end of the next turn (barring collisions, etc.). In order to do this properly, I’d need to essentially run the physics for another turn, get the final location of the vehicle, then “rewind” to show the vehicle in the right position, but have an indicator of where the vehicle will be barring any changes. If you’re going straight, the indicator would show the “end of next turn” indicator as being directly ahead, but if you pick the option to turn left instead, it would need to calculate the new position to your left and show the indicator there before you accept the command and actually execute the next turn. Does anyone have any ideas for a way to do this?

  • Once basic maneuvering is handled, I’d need to start implementing more advanced maneuvers, such as bootlegger turns, powerslides, etc. Any thoughts on how to “script” these maneuvers, so they can be essentially replayed over the next turn (i.e. accelerate for 0.2 seconds, then brake + hard left for 0.5 seconds, then moderate right for 0.3 seconds to level out)?

Thanks in advance.

Q2: Perhaps not possible. Implementing a maneuver template that works perfectly on a flat surface with a uniform terrain surface type (asphalt or grass or sand or gravel) might be doable. Implementing a maneuver template that handles all possible cases of terrain slopes and surface type combinations would seem to be unsolvably complex.

Q1: Predicting position using a ghost car… I haven’t tried out my new idea yet but here is my proposed approach:

I’m going to project the vehicle’s position 1 second in the future with 0.1 second delay by modifying the game time variable to 10 x its usual rate during the “pause mode” when players determine and submit their next move. I will revert to normal time during “execute mode” when player input is disabled and the ghost cars are hidden.

Modifying the rate at which time passes in-game is pretty much universally considered a “bad idea”. Emitters such as the smoke and flames from destroyed vehicles nearby would need to be correspondingly modified so that flames didn’t flicker 10 times faster and smoke billow 10 times faster during “pause mode”. I am sure there are other significant drawbacks to monkeying with the passage of time.

I’ll still be setting the vehicles kinematic during “pause mode”.

Vehicle ghosts will take the transform values of the corresponding vehicle and won’t be kinematic. I don’t want the two colliding when one instantiates inside the other. With current user input values, one tenth of a second later, that vehicle’s predicted position will be shown by the ghost and then the ghost becomes kinematic.