Hi , i know that the first person controller from unity standard assets has that functionality i dont really know how it works.
But you can create an OnTriggerStay2D to get the velocity of the plataform.
function OnTriggerStay2D(PlatformCollider : Collider2D){
if(PlatformCollider.tag == "Plataform"){
var platformVelocity = PlatformCollider.GetComponent(Rigidbody2D).velocity.x;
rigidbody2D.velocity.x = platformVelocity;
}
}
For this to work your platform and player should have rigidbody2D and the platform must be moved by addForce or Velocity and not by transforming or animating the position.
**EDIT**
Remember to use 2D Colliders and 2D RigidBodies , and to set your player Collider to "IsTrigger" you should add 2 2D Colliders to your player one for the trigger events and other for collisions.
I left you the test project i made. press left or right to move the plataform and press jump (space bar) to move the "player" to the right.
http://www.mediafire.com/download/132ilw84vpc5ps9/plataformTest.zip
↧