- Home /
On collisionenter name == redblock
I am making a game as cube field and I want if I collide with a block I am game over so here is my script:
pragma strict
var Unitygameover : GUI; var RedBlock : GameObject;
function OnCollisionEnter (collision : UnityEngine.Collision) {
Debug.Log("Game Over"); if(collision.gameObject.tag == "RedBlock"){ Debug.Log("Hit the RedBlock");
} }
function Update () {
}
But if I play the game and I collide with the Redblock Nothing happens can you please help me.
I'm from the Netherlands so sorry if i have made spelling mistakes
$$anonymous$$aybe change UnityEngine.Collision to Collision , and make sure the object that collides is either a rigidbody or a character controller. And, also try and enable the redblock "IsTrigger" mode.
collision.gameObject.tag
Are you sure you have tagged the gameObject properly, the title of the question suggests that you renamed it "RedBlock" rather than tagging it as such
Crystalline if i change UnityEngine.Collision to Collision i get an error and the object and the player do have an rigidbody so that isn't it. I have also tried istrigger mode but that didn't help either.
Your answer
Follow this Question
Related Questions
Game Over GUI Question 2 Answers
GUI.Box within a Collider 1 Answer
Setting Scroll View Width GUILayout 1 Answer
Problems with OnTriggerEnter 1 Answer
Is this a problem of unity 3 or i am doing something wrong. 1 Answer