- Home /
Duplicate Question : http://answers.unity3d.com/questions/440716/unity-wont-detect-when-my-objects-collide-1.html
Unity wont detect when my objects collide?
Hi guys, I'm having trouble with my Unity C# script for Collision, and I was wondering if maybe you guys can help me.
void OnCollisionEnter(Collision target){
if (target.rigidbody.tag == "player"){
print ("bang");
if(drilling == true){
Destroy(gameObject);
}
}
}
My goal is to destroy the object when the player collides with it. but not be able to walk right through it either like what happens when i try the trigger code. I added the print section just to check where the problem was, but it wont print anything at all.
I am a JavaScript nerd, so I am not sure about this, but Don't you need "player" in ( ).
Also are you using the default tag "Player" in Unity, if so you might just need a capital "P"
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Unity wont detect when my objects collide? 4 Answers
Multiple Cars not working 1 Answer
How to detect collision on only one side of an object? [C#] 4 Answers