I’d like to make a Snooker/Pool game to learn more about Unreal and AI. A snooker AI would be required to consider the end position of the cue ball after a shot in its decision making, so I was wondering, is there a way to predict the outcome of applying physics in advance (e.g, predicting the end position of the cue ball after taking a shot?) I am assuming here that applying an impulse to the cue ball would be the best way to implement this but don’t know how to predict where the white will end up in advance. Can anyone offer any advice?
I would create duplicate balls that use their own collision channel. This collision channel would allow them to collide amongst themselves and the table, but not with the original balls. Place the duplicates at the same transforms as their respective originals, then apply your force or impulse to the duplicate cue ball. Once they stop moving, you’ll have an idea of what their final transforms are for that force/impulse. Keep in mind that the physics engine is non-deterministic. The duplicates having the same transforms will result in slight, or possibly drastic, differences in the actual final transforms of the originals even if your’re using the same impulse/force. Consider enabling substepping, which may help minimize these differences. If I needed the originals to end up in exactly as the duplicates, I would save the transforms of the duplicates during the ‘simulation’ then apply them to the originals, as if replaying the duplicates simulation with the originals.
Thanks, do you know if it’s possible to run the whole simulation in a single frame (or over a very small amount of frames) and if so how I go about speeding up the simulation so it completes as fast as possible
Time dilation might work as far as speeding up unreal’s physics. If you want it done as fast as possible you’ll probably have to roll your own system. Setting up a predictor-corrector that accounts for drag and calculates the elastic collisions of the billiards would be relatively straight forward. It wouldn’t be specific to the Unreal Engine but would get you positions without worrying much about the time frame to determine them.