Projectile Issues

I am making a game. It uses projectiles that will bounce off the wall once. but theres a problem. The projectiles go through what there suppost to hit some of the time. they use ridgidbodys for movment, force applied when launched and thats all. any ideas?


Collision is checked on every frame. If your speed is so high that between frame a and b your object moves through a collider, nothing can be done about it using collisiondetection. To fix this you want to 'predict' where your object will be in the next frame.

The easiest way to do it is casting a ray ahead and see if it intersects with an object in front of it at a distance of currentspeed*Time.deltaTime.

These's an advanced version of this script already out to be used freely over here on the wiki.


Edit since my assumption that is was due to speed was wrong:

The other obvious reason for this behavior would be that you're directly setting the transform of the components that have a rigid body component attached to them. When you attach a rigid body you let the physics engine take over on that object, if you then also directly change it's transform yourself unexpected things can happen. Try to use AddForce and other functions you can find here, rather then directly accessing the transform. Or remove the rigid body, of course.

If this is also not what is causing the problem, please be more specific about what you're actually doing that might be causing this.