I’m currently working on a cricket game (PC) and want to achieve realistic bowling. I have tried something by applying some force on the ball. I’m new to this and would like to how bowling is implemented in games and if have a suggestions please tell me.
I would suggest using unity physics for the gravity and ball bounce, and adding in your own pseudo real physics for the other features.
Assuming you want…
curve in the air from polish on one side of the ball…
bounce off grass from spin on the ball
bounce off grass from seam
possible some kind of skid low, or bounce high, based on spin also.
IF you are doing slo-mo camera so you can see what the ball is doing… you might want to do things more accurately…
Cheap version… for curve in air, just add a side force to accelerate the ball left or right… until ball bounces.
Accurate version… do dot produce between ball travel direction and ball’s right vector (shiny or dull side of ball) when dp result =0 do maximum curve force, when its 1 or -1, do no force… this is accurate and will work and look right in slo mo also.
for spin / seam deviation, 2 and 3 have onCollision check, and modify the forward vector when the ball bounces… (and stop lateral ball spin… add forward ball spin) You will have to experiment here with how much force to add, based on some magic constant K, ball speed, spin rate, and bowlers skill value, and if you want… surface grip. (more grippy in dry weather / yellow grass. more slippy with green grass)
skidding/kick. not sure if Unity can do this built into its physics… but if not, you’ll again need to modify the vector after collision… this method can also be used for spin deviation, but not seam…
get axis of rotation from rigid body, and add force in direction at 90 degrees to the spin axis * spinRate * K, and also some to the Y velocity (increase or decrease) to reduce bounce or add higher bounce.
for 3) seam. either add random left right direction deviation, or random left/right force.
If it needs to look accurate in slow mo camera… then you’ll need to figure out if the seam is hitting the floor… which would be if the Right vector is nearly horizontal… (assuming right vector is at 90 degrees to the seam) then apply force along right vector depending if the seam is tilted left or right (check Y component of right vector to get the tilt)