- Home /
Problems with Triggers
A trigger script that I'm using activates too early displaying the text "Hi" before any objects hit it. also how can I make sure its the player hitting the object
function OnTriggerEnter (other : Collider) { print("Hi"); }
Answer by DaveA · Jan 19, 2012 at 12:05 AM
Check the collider's size.
You can look at other.name == "Player" or other.tag == "Player" or whatever (assuming your player object is called or tagged "Player")
The trigger is normal size but its still doing it any more help
Answer by LegendSeekerX · Jan 19, 2012 at 03:44 AM
In the OnTriggerEnter function, do an "if" test to see if it's the player hitting the trigger. Also, make a "Player" tag if you haven't already, they're pretty good for doing these simple checks.
Might look something like this
function OnTriggerEnter(other : Collider){
if(other.gameObject.CompareTag("Player")
{
print("Hi");
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How to make the trigger work only once. (SOUND) 1 Answer
Unity3d won't open anymore 7 Answers
Problem in 2D Gun Rotation 1 Answer
IndexOutOfRangeException: Array index is out of range 0 Answers