# how to force the ball after collision with bat?

Making a cricket 3d game. when ball touches the bat it stop however where bat touches.
my question is how to force the ball where the bat moves.

I donâ€™t have specific information on how to do this, but one thing I can offer is perhaps a different way of thinking.

Most games fake things. The more important it is to the gameplay, the more itâ€™s faked.

By this I mean although Unity has a physics system, you probably donâ€™t want to use that straight out of the box for your ball movement if the way the ball moves is really important for your game. Baseball games donâ€™t have a bat with a cylinder collider and ball with sphere collider that just have both move and react to each other, for example. When a batter makes contact with the ball, the game would do some calculations to determine where on the ball contact was made, the speed and angle of the bat, the spin of the ball, etcâ€¦ to determine the ballâ€™s outward trajectory. And probably none of it based on the actual physical properties of those objects as they exist in the game, but rather as a series of properties of data behind the scenes.

Maybe another better example: shooting games donâ€™t simulate the way the gun actually works. As in, the player clicks the Fire button and the game simulates the trigger mechanism releasing the hammer, which then strikes the firing pin, which ignites the propellant, which then expands and forces the bullet down the barrel towards its target. Instead, you can assume all that stuff happens and figure out a few numbers associated with the result, and use those to determine the important part of your sim: where the bullet goes.

So for your game, when the player swings the bat and makes contact, consider figuring out how hard they were swinging, where they hit the ball, and then use that information to â€śswitch offâ€ť the bat and just do an ApplyForce on the ball in the appropriate vector.

Does that make sense?

4 Likes

Could you go into more details, on this part.

Well, I meanâ€¦ Like, youâ€™d definitely use math, andâ€¦ other thingsâ€¦ to figure it out, andâ€¦ then youâ€™ll be saved.

1 Like