I am making a simple baseball/batting cage “game.” It only consists of a pitching machine and a bat floating in mid air that rotates around. The problem is that the balls pass through the bat (not always, but most times). The bat has a capsule collider and the ball a sphere collider.
I tried to use a Physics.raycast t help determine when there should be a collision even if the collision detection system misses it, but it seems my raycast are also passing through the bat sometimes. I get inconsistent behavior, but the raycasts always “sees” the objects behind the bat however. This happens even when the bat is stationary, and placed in a direct path of the ball. Drawing the raycast shows that it and the ball are literally going through the bat!
Right now the objects in the game are fairly large. I added a cube to the scene to see how big things are in unity units, and the baseball is about 1/3 to 1/2 size of the cube, and the bat’s collider has roughly the same radius as the cube, and is 3-4 times as long. I dont want to make things any bigger if i can help it.
The code i have for raycast is directly from the docs…so I wont post it here.
Anyway, Im getting pretty irritated, because this should be the easiest part of the coding process.
I just want consistent collision detection!! why is this so hard to ask?!