- Home /
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;
}
Your answer
Follow this Question
Related Questions
Audio Trigger Enter Exit 1 Answer
How do I have the object disappear once the FPS controller looks at and then looks away. 0 Answers
i need detailed instructions... cue texture 1 Answer
on trigger enter 1 Answer
OnTriggerEnter problem 3 Answers