- Home /
Again about the platforms...
Hi all! I making small game for android and have a problem with platform and character collision... On picture You can see components and there code for platform:
#pragma strict
var platform : Transform;
var player : Transform;
function OnTriggerEnter (other : Collider){
if (other.tag == "Player"){
player.transform.parent = platform.transform;
Debug.Log(OnTriggerEnter);
}
}
function OnTriggerExit (other : Collider){
if (other.tag == "Player"){
player.transform.parent = null;
Debug.Log(OnTriggerExit);
}
}
And there code of moving platform:
function Start(){
iTween.MoveBy(gameObject, iTween.Hash("x", 2, "easeType", "easeInOutExpo", "loopType", "pingPong", "delay", .1));
}
When character is jump and fall on platform he truely moving with it (but little slow and falls behind platform) and Debug writing in console what character OnTriggerEnter, but when he jump from platform he keep moving with platform transformation and Debug is silent in console about OnTriggerExit. What did I do wrong?
P.S. Character controller and platform both have Rigidbody and IsKinematic. Platform have two colliders: box and mesh. Box collider is trigger.
Thanks!!
I think it's because you're parenting the player to the platform. Probably means you can't exit the trigger because the player is also part of the trigger now.