|
Hi, I added a rigid body to my player that I can control and move around the arena. I have the following C# Script which detects if my player has 'stayed' or 'exited' the Plane game object:
Just wondering why. What I don't want to do is this:
Which works, but can this be done only in the subrountine OnTriggerExit? I am all ears.
(comments are locked)
|
|
It seems like you think "OnTriggerExit" is called repeatedly if the object is not in the trigger. That is not the case, as it is only called once on the same frame the object leaves the trigger. Therefore you will have to use a boolean to control the logic flow similar to what you have in the second set of code. Also if this is for points or something similar you should use something like Time.time or Time.deltaTime to do this over time, otherwise it will happen every frame causing the incrementing/decrementing to be frame dependent rather than time dependent, and very fast in most cases(shooting to 50 or zero in less than a second). Awesome post thanks so much =)
May 22 '10 at 04:59 AM
lampshade
(comments are locked)
|

If you don't want the Update, you could always just start a coroutine with OnTriggerEnter and stop the coroutine with OnTriggerExit.