- Home /
Character is pushed off platform only when moving
I'v been trying to get my character to stick to a moving platform, great that works, but only if standing still otherwise the character is pushed off the platform very violently.
I'm using a simple trigger script to trigger the parenting of the player to the moving object, the trigger box collider is parented under the platform and the player is parented to the collider once triggered.
#pragma strict
function OnTriggerStay ( other : Collider )
{
if (other.tag == "Platform")
{ this.transform.parent = other.transform.parent; Debug.Log ("A", this); }
}
function OnTriggerExit ( other : Collider )
{
if (other.tag == "Platform")
{ this.transform.parent = null; Debug.Log ("B", this); }
}
Comment
Your answer
Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
Triggering platform animation on colliding with Button 0 Answers
Use trigger with player but have a collider with everything else? 3 Answers
How do you go from one scene, to another, then a third and back again ? 0 Answers
Stop object colliders (non-mesh) bouncing on collision 1 Answer