- Home /
OnTriggerEnter is called anyway
Hi Guys and Girls,
I have been using snippets of code like this for years,
function OnTriggerEnter(other:Collider)
{
if(other.gameObject.tag == "Player")
{
print ("Sending Message");
GameObject.FindWithTag("Pistol").SendMessage("AttachSilencer");
gameObject.renderer.enabled = false;
Destroy(gameObject,1);
}
}
But this one, activates all itself. I am nowhere near to object that this script is attached to, and I am the only object tagged "Player".
Just like to point out as well, that the Function "Attach Silencer" is only sent from this script, I assure you no other. Is this a glitch or is there something I don't know about OnTriggerEnter?
Even if you're sure there's no other object tagged Player, please check it again. Please also check if you didn't add this script to another object.
To do a quick check who participates in collision, add these lines to your code:
print("I am: " + this.name);
print("Collider is: " + other.name);
Your answer
Follow this Question
Related Questions
Activate / Deactivate objects onTriggerEnter / Exit 2 Answers
UI Button ON/Off 3 Answers
on / off if statement C# 1 Answer
activate script from trigger 1 Answer