- Home /
Fixing problem with collisions.
@ScaniX using UnityEngine; using System.Collections; using UnityEngine.UI;
public class TinCansDestroy : MonoBehaviour {
void OnCollisionEnter(Collision collision){
{
if (collision.gameObject.CompareTag ("TinCanDestroyed"))
return;
TinCanGame.instance.OnTinCanDestroyed ();
collision.gameObject.SetActive (false);
}
}
}
this is the current code but the ball is still destroying the walls, floor etc. I'm restarting the question here because of that stupid bug.
Comment
See one of my last comments in your previous question. ;)
The ! in the if is missing, it should be:
if (!collision.gameObject.CompareTag ("TinCanDestroyed"))
return;
Your answer
Follow this Question
Related Questions
OnCollisionStay for seconds then destroy 0 Answers
Instantiate 1 object after 2 objects collide. ( C# ) 1 Answer
Destroy Turret with machine Gun 0 Answers
Destroy a GameObject 2 Answers
Create hinge joint 2D by collision 2 Answers