I have a game where a ball is hit into a hole (think something like pool). I would like to do two things:
“ghost” a line to where the ball will go once hit
Move the camera to where the ball will end up after it is hit to nicely watch it
Both these tasks require knowing where the ball will end up/travel, and I’m not sure the best way to do this. Is it possible (and suggested) to speed up the time step to calculate what happens ahead of time? Or is there a better way to do this?
A) Set up your own functions for movement and don’t use rigidbody physics, that way you can always evaluate your functions of movement in realtime with less impact on performance. Of course this is only a feasible solution if your laws governing the movement are simple enough compared to the effort of predicting rigidbody movement.
Invisibly “playing back” the rigidbodies has the drawback of being slow, because you can’t just make time faster without affecting the other deltaTime-dependent aspects of your game, like controls and stuff.
B) If you stick with rigidbodies, you can still compute approximate trajectories for them. For example you know where you’re shooting it, so a raycast will give you the first line. After that, you know the ray’s incoming angle so you can easily calculate an outgoing angle when the ball will bounce off the wall. Of course you must take into consideration the starting velocity of the ball, and use simple enough physics settings so you can actually mimic them in code.
C) There are existing questions and answers on this topic, run a search for it. I’d definitely go for something that’s not too heavy on performance.