I am creating a flight sim. And now I am in the middle of collision detection script.
Here is my script:
I have an EmptyObject which I named Jet. which is the father of all children objects (paritcle effects, model, colliders, spawnpoints and etc.) for the collider I have another father which has only Rigidbody and isKinematic is positive. It has 5 children colliders which are all triggered.
a quick explanation for the variables: jetModel -> is only the jet model, which also hold the particle effect (engine).
jet -> is the main EmptyObject which holds everything.
terrain -> is the terrain.
groundExp -> is the crash explosion.
My script was working, when I had mesh, and convex, however, mesh is glitchy anyway in Unity3d so I had to add multiple specific colliders.
Right now, when everything is triggered on, the only thing that works is the OnTriggerExit, when I'm out of bounds.
I have several issues.
When none of my triggers are triggered, Unity from some reason actually detect the collision, and the jet explodes when hits the ground.
Problem 1: sometimes the particle effects remain for a moment until the script disable all of the children. (which I don't know why it has a delay)
Problem 2: when I hit the water, which actually several colliders hit the water, then my script runs multiple times for every collider that has been collided.
Problem 3 (which related to 2): When I hit the water, I added a little effect which let the jet "sink", However when it collides with the ground (terrain) it explodes in the water.
I had a fix for that, which I disabled the triggers for the collision and then even if the jet hits the terrain in water, it doesn't explode. However, I can't access it from 2 reasons:
A) There are no triggers actually working, if they did, unity wouldn't detect the collision. B) I don't know how to access all of the triggers and disable them.
Okay I have fixes for my own problems.
1) It was a collision with 2 scripts, which 1 turned the particles on, and another script that tried to shut it off.
2) What I did was shutting off "isKinematic" as soon there's a collision. very rarely I have to exact collision. so I did lower a bit one of the colliders to make sure it won't happen.
3) This is related to my 2nd solution.
answered Jul 23 '12 at 06:15 AM