- Home /
Destroy cube when player collides
Okay I want to make it so whenever the player collides with any game object with the tag "enterBattle", Here is the code I have, this is in the player script by the way:
function OnCollisionEnter(collision : Collision)
{
if(collision.gameObject.tag == "enterBattle")
{
Destroy(collision.gameObject);
}
}
Seems like that should work. Does your player or the object it's colliding with have a rigidbody? And you don't have isTrigger checked on your player or other object's collider's, do you?
Check enterBattle tag spelling is correct.
also set isTrigger unchecked on your player or other object's collider's.
Some moderator converted this answer to a comment before the answer was accepted. -1 Answers bug invoked!!
and seems that in moderator page is still comment there, ...
I converted many answers in to comments before they were accepted and this behavior didn't happen, ...
something else had to happen
and there's always my signature "don't post answers as comments"
Your answer
Follow this Question
Related Questions
Why is my object getting stuck in the edge of other objects? 2 Answers
How to detect collision between 2 objects while checking are they the ones that need to collide? 1 Answer
How to do collision of external objects on script? 1 Answer
How do i understand which gameObject is player touching ? 1 Answer
Mesh Collider doesn't work without reset 2 Answers