Problem w/ collision

Updated on April 28, 2017 in [A] Other Answers
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
5 on April 25, 2017

I have a laser object and the ground object.  Both have box colliders and the laser has a rigidbody.  No matter what I do, Unity can’t seem to detect the collision between them.  Here’s my code:

 void OnCollisionEnter (Collision other){
 if (other.gameObject.tag == "ground") {
 Debug.Log ("Laser IS touching ground");
 //DestroyObject (this.gameObject);
 } else {
 Debug.Log ("laser NOT touching ground");
 }
 }
 

Does anybody have any ideas?

  • Liked by
Reply
0 on April 26, 2017

bump

  • Liked by
Reply
Cancel
3 on April 26, 2017

Maybe use Triggers instead?

on April 26, 2017

The problem using triggers is that the player passes through the ground object.

Wise
on April 27, 2017

You could use one trigger and one collider, (just make the trigger a small amount bigger.

An other thing you could do is, using raycast to detect the ground.

on April 28, 2017

Okay, so I used triggers on the laser instead, and it works fine.  Thank You for your help!

Show more replies
  • Liked by
Reply
Cancel