I’m building a billiards game in which I want to predict the trajectory of the cue ball before shooting to help the player line up their shots.
Currently I have a basic version working with Raycast but the issue is I’m planning to add some objects to the table that will affect the trajectory of the ball. The objects can result in complex movements of the cue ball which I feel like might be hard to replicate correctly with Raycasts.
Therefore I would like to simulate the shot on an invisible table first and then record the trajectory of the cue ball during this invisible shot to create the helper display.
I want this simulation to run once every frame for the current shot configuration (i.e., hit direction, power etc.)
Is there any way to create such a simulation that essentially records the trajectory in a sped-up invisible table so I can record the trajectory every frame?
It’s worth noting that _process() runs for a node even if visible == false. So you could, in fact, have an entire duplicate of the table with visible set to false for its root node and have that run the simulation for you.
I imagine you’d then find a lot of extraneous stuff you could get rid of, but it also gives you the option of (say) animating the projected trajectory with translucent balls over top of the “real” table…
Do you know if I could speed up the simulation somehow without breaking the game itself?
Because I need the entire shot simulation to be done before next frame in order to draw it.
If there was a way to manually step the physics engine for the simulation table without breaking the game, I could simply run the shot as fast as I can in the simulation and record the trajectory, then simply draw it before the next frame.