- Home /
Why is my OnCollisonEnter not working?
hey guys my collision isnt working could you please check the script it attached it to the rocket launcher thanks
public class findweaponrocket : MonoBehaviour {
private string text = "Press F to pick up the weapon, you got the rocket launcher!";
// Use this for initialization void Start () {
}
// Update is called once per frame void Update () {
} void OnCollisionEnter (Collision collision) { if (collision.collider.tag == "Player") { Destroy (gameObject); // this destroy is for debugging puporses text = GUI.TextArea(new Rect(10,10,200,100), text, 200);
}
} }
Answer by gribbly · Aug 27, 2012 at 08:33 AM
Did you forget collision.collider in front of gameObject? Also try using Debug.Log...
void OnCollisionEnter (Collision collision) {
Debug.Log("do you see this message?");
if (collision.collider.tag == "Player") {
Destroy (collision.collider.gameObject); // this destroy is for debugging puporses
text = GUI.TextArea(new Rect(10,10,200,100), text, 200);
}
}
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
OnCollisionEnter doesn't work - C# 1 Answer
Multiple Cars not working 1 Answer
generate GUIText at runtime C# 3 Answers
A node in a childnode? 1 Answer