Hi, so i have a very fast moving rigidbody and i want it to bounce back after hitting the bat (another rigidbody) but for some reason at high velocity, it seems like it going through the bat. There are no constraints set on the rigidbodies and the collision is set to discreet. Can anybody help?
You should always set the collision detection mode on the Rigidbodies to be “continuous dynamic” for fast moving objects, hope this helps.
Have you tried doing it with a lower velocity to make sure it works?
Remember that Update() is ran every FRAME. If there is no frames where the ball is touching the collider there will be no collision. ie. Frame 500 ball is at 500, 0. Target is at 700, 0. But Ball is traveling at 300units per frame. The next time update is called, ball will be at 800, 0.
To solve this, use Continious Collision Detection instead of discrete collision detection.
Although I’ve never used it, a quick google also pulled up DontGoThroughThings which uses raycasting to avoid the physics engine allowing fast-moving objects to go through other objects. Here is another thread about this.
You could try to raise the physics time step. So the physics collision detection is processed more often per second.
Edit → Project Settings → Time → Fixed TimeSteps.
If that doesn’t work, try to make the collider of the bat larger, so it’s easier to hit within a physics update. You can also try to lower the velocity to make sure everything is setup correctly. The colliders have to have the option “is Trigger” set to false and the rigidbody has to have the option “is Kinematic” set to false too