x


OnTriggerExit() help

Im having trouble with OnTriggerEnter and OnTriggerExit

I have it set so that my player becomes a child of a platform when the player enters the trigger (which is an empty game object above the platform). Once this happens though I am unable to exit the trigger and remains parented to the platform. The point of the code is for the player to be parented to a platform so he/she does not fall off the platform while it moves and to become un-parented from it when they leave the trigger object. The following is my code:

var player : GameObject;
var platform : GameObject;
function OnTriggerEnter(trigger : Collider)
    {
       print("enter");
       player.transform.parent = platform.transform;

    }


function OnTriggerExit(trigger : Collider)
    {
       print("exit");
       player.transform.parent = null;
    }
more ▼

asked May 20 '12 at 09:11 PM

LeeRoy88 gravatar image

LeeRoy88
0 1 1

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x980
x146
x72
x58
x57

asked: May 20 '12 at 09:11 PM

Seen: 421 times

Last Updated: May 20 '12 at 09:11 PM