- Home /
On Trigger enter won't register
Well, I set the "sm" tagged object and the player object to Ontrigger in the scene, and put ScoreKeep.js(the script below) on the player, the gui won't register and change when the player passes through the "sm" object. I can't even get confirmation that OnTrigger enter occurred, but in the the scene, I can see the player passing through the "sm" object.
var score = 0;
var scoreText = "Score: 0";
var mySkin : GUISkin;
function OnTriggerEnter( other : Collider ) {
Debug.Log("OnTriggerEnter() was called");
if (other.tag == "sm") {
Debug.Log("Other object was a score marker");
score += 100;
scoreText = "Score: " + score;
Debug.Log("Score is now " + score);
Destroy(other.gameObject);
}
}
function OnGUI () {
GUI.skin = mySkin;
GUI.Label (Rect (10, 10, 500, 200), scoreText.ToString());
}
Please help, its probably a small thing that I missed.
Answer by Bunny83 · Sep 24, 2012 at 01:19 AM
Does one of the objects (usually the moving object) a rigidbody attached? If not you won't get any collision or trigger messages since they are generated by the physics system.
Your answer
Follow this Question
Related Questions
Drag gui text and drop it on 3d object. 0 Answers
Searching for gameobjects with a tag and creating a button for each one? 1 Answer
Pointers to Show Off-Screen Enemies 1 Answer
Text appear on screen when I stand over object. 1 Answer
Moving GameObject Towards Spot when clicking a GUI Function 1 Answer