hi i need help with colliding bullets when i set the speed to be to big they don't collide with the wall please help
asked Feb 25 '10 at 02:40 AM
The problem might be that through the high velocity of your bullet, the fixed frames in which your application is running are not enough to register your collision with the wall. In one fixed frame the bullet is in front of the wall and during the next fixed frame, the bullet already went straight through the wall. Everything that happens in between has no consequence for registering a collision.
One approach to avoid this problem is to use a raycast and build your logic of hitting the wall with the bullet on whether and where the raycast hit your wall.
There is one script on the Wiki which might of of help.
There is also some discussion about this issue in this forum thread. However, I believe just increasing collider size is not an ideal solution, because you will eventually be running into problems (literally!) when characters or other objects collide with your wall even though they are still at a distance to the actual rendered wall.
edit: A working example of a script for firing a bullet and using a raycast can be found in this forum thread.
you can increase the number of fixedUpdates. go to edit/project settings/physics and reduce the value of fixed delta time. this will have a performance penalty for you but you'll have more FixedUpdates so the collision will be registered. the best approach is to use raycasts as sebas said. unity checks for collisions in FixedUpdate and in your application the collision can not be registered because the velocity is too high and in a FixedUpdate the bullet is in one side of the wall and in the next FixedUpdate it is in another side. increasing the number of fixedUpdates can help but you can make sure to have all collisions registered with raycasts.
answered Feb 25 '10 at 05:10 AM