Hello All,
var other : Rigidbody;
var ball = 0.0;
function OnTriggerEnter(other : Collider)
{
ball++;
}
When I add this script to a empty GO with a sphere collider and IsTrigger is checked, I get an error.
Thanks,
Ray[/code]

Hello All,
var other : Rigidbody;
var ball = 0.0;
function OnTriggerEnter(other : Collider)
{
ball++;
}
When I add this script to a empty GO with a sphere collider and IsTrigger is checked, I get an error.
Thanks,
Ray[/code]

I got it,
I was writing some script that had an error (not being used) before I wrote the OnTrigger Script, After the error was corrected, I was able to add the script to the empty GO.
Hmm…
Oh, good. ![]()
A couple things though…you have “other” defined as a type Rigidbody and later as a type Collider. A variable can only be one type, so just get rid of the first line. If you’re just incrementing “ball”, it’s an integer, so ideally you’d use “var ball: int = 0”, instead of 0.0 which means floating point. (I’m assuming Unity processes integers faster than floats…not that it will make any noticeable difference in this case, but still, good to get in the habit I guess.)
–Eric
Hi Eric5h5,
Thanks for the tip.