Projectiles passing thru colliders

Not sure if anyone else has experienced this problem before but from the original fps tutorial, the rocket launcher uses projectiles and explosions, and ive used that and implemented it into my game but for some reason, when I set the velocity (speed of the projectile) to around 40 the actual projectile sometimes shoot right through a wall collider, some times it doesn’t.

Now the wall collider is about 0.4 units thick and the projectile is a sphere collider about 5 units big, so its not like it should go right through, and I cant seem to fix this issue, and I dont want to decrease the speed of the projectile, I was hoping to increase it to about 60 but that just increases the chances of going through a wall collider.

Anyone know how to fix this problem?

My basic setup of the gun and scripts are exactly the same from the fps tutorial from the rocket launcher, so I dont think I need to post up any scripts of mine.

Thanks in advance.

I can’t comment on the exact values you’re using (object size, speed, etc.), but it certainly sounds like tunneling.

Maybe others can offer different suggestions, but raycasting may be your best here. (There’s a script floating around called DontGoThroughThings that uses raycasting to try to avoid tunneling. I can’t say myself how effective it is, but it seems to be suggested fairly often as a solution to this particular problem.)

Im trying to use raycasting but its SUCH a big annoyance, and ive had so many problems with it, as you can see on this thread. http://forum.unity3d.com/viewtopic.php?t=58874&highlight=

Thats why I decided to go back to projectiles that works perfect except the fact that it doens’t collide all the time…

You mentioned tunneling? Ive never heard of that term before but im trying to find that script, thanks for mentioning it.

EDIT: Okay well ive found it http://www.unifycommunity.com/wiki/index.php?title=DontGoThroughThings but im not sure how exactly to use it.

I’m not sure what’s causing the problems you described in your other thread, but I doubt the problems are related to raycasting specifically. In any case, raycasting shouldn’t be an annoyance; it’s a very common technique that is used all the time.

As for the DontGoThroughThings script, just try adding it to your projectile prefab, and see if it has any effect on the tunneling you’re seeing. (Tunneling, by the way, is just a term for what you’re seeing here: objects passing through other objects due to the use of discrete intersection tests.)

I tried the DontGoThroughThings script and I didnt see much of a difference, I changed up the SkinWidth variable from 0.1 through 10 and did not see a difference.

As for the raycasting, the issue I have is when the gun shoots, its suppose to show particles, but since im using a detonator with a collider and rigidbody, it didnt seem to work (And i need that stuff for other purposes such as blood effects on enemies). So technically the detonator effect isnt a particle, its more of a rigidbody or gameobject, so thats where my problem was.

My solution has been to use an ultra long collider around a bullet that is longer than the bullet itself, not perfect however it means there is more to collide per frame.

I’m going to use raycasting though as its better. Just look at games like Arma that use projectiles, they are realistic in a sense however the actual playability sucks. MW2 for example uses raycasting and its more fun.

I would be interested to see if the tunneling issue has been addressed in Unity 3 as the physics have improved, anyone educate me on this?

In Unity 3.0, the Rigidbody component has an option called continuous collision detection. This has higher CPU overhead, but it is very good at stopping fast-moving objects from going through other colliders.

Hi everyone!
I’ve been testing things in a simple scene where I shoot small spheres at a big sphere and have experienced wierd results. I’m wondering if the reason might be the same. These are the parameters:
big sphere:
scale: 10
sphere collider

small sphere:
scale: 0.1
sphere collider
rigidbody
instantiated with a “force” of 30

Now if they collide offcenter the small spheres bounce back, but if they collide at the center of the big spher they don’t. They kind of move along the surface slowly or sometimes just stick to it.
I tried changing the scales and the force but the results didn’t change.
I also tried using a large cube instead of the sphere and experienced similar results, almost as if the problem resulted from the surface normals of the contactpoints being in the same line.

I hope my description is precise enough and I’m really interested in possible answers, maybe they can help others as well.