- Home /
OnTriggerEnter Glitch
I have this code below
#pragma strict
var Master : GameObject;
function OnTriggerEnter(other : Collider){
if (other.tag == "ActBot"){
Master.GetComponent(UBotController).Points += 100;
}
}
So basically if this trigger comes into contact with another object tagged "ActBot", then it will reward the Master with 100 points on my UBotController script. The master GameObject also happens to be tagged "ActBot" and there is another object (that i am colliding with) has the tag "ActBot" AND has my UBotController script attached.
For some reason when the trigger goes to collide with the other object tagged "ActBot" it gives points to both the objects using the UBotController script. And i have no clue why it is doing this? can anyone help?
Is there any parent/child relationship between ActBots? Sometimes the parent tag or name is pulled from the Collider object, not that of the child.
Both ActBots are children to two seperate, Untagged gameObjects and the trigger's parent is one of the ActBots
Answer by jenci1990 · Dec 03, 2014 at 06:52 PM
Is UBotController.Points static variable? If it is static, set it to simple public: public var Points;
it's a static variable. just changed it to public and it works properly now! Thanks for the help!
Your answer
Follow this Question
Related Questions
Fog On and Off Script Help! 2 Answers
Losing hp 1 Answer
I keep getting an error when try to change the tag of a gameObject 1 Answer
OnTriggerEnter fired incorrectly (android device only) 0 Answers
Jumpscare script help!! 1 Answer