- Home /
OnCollisionEnter called twice
when the rocket hit a wall or something...itsupose instantiate an explosion and then destroy it,but 2 explosion prefab and sometime 3 aapear...and there is only one sphere collider to the rocket...and i also tried to destroy the rigid body on the collision enter so i dont know mayne!!!
var Death:Transform;
var Dead=false;
function Start()
{
rigidbidy.AddForce(0,0,100);
}
function OnCollisionEnter(Hit:Collision)
{
if(!Dead&&Hit.gameObject.tag=="Terrain")
{
Dead=true;
Instantiate(Death,transform.position,transform.rotation);
Destroy(gameObject);
}
}
Answer by mhdema n9ne · Nov 13, 2013 at 01:09 AM
I've encountered similar issues in the past you should make sure you aren't generating one too many objects or accidentally attaching duplicate components.
I think your Kinematic solution might be a workaround to resolve an issue somewhere else. From your description it shouldn't play a role in the issue itself. Here is info on kenimatic: http://docs.unity3d.com/Documentation/Components/class-Rigidbody.html
You could try DestroyImmediate but again I think there might be a larger problem. http://docs.unity3d.com/Documentation/ScriptReference/Object.DestroyImmediate.html
Answer by hotozi · Nov 12, 2013 at 09:47 PM
for those who want to know how i deal wit it... well i dont know why but it works...i set on the kinematic thing...so look like the function dont call twice....well...
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Gui placement help 1 Answer
Disabling Rigidbody constraints on GameObject that script is attached to 3 Answers
Yield function goes slow sometimes/differently? 2 Answers
How can i fix this error? 2 Answers