Why does the Rigidbody not move

Hi @ all members

i have a moving platform, the moving platform has a box collider with Trigger active.

the platform has following script attacht.

function OnTriggerEnter (hit : Collider) 
{ 
	
   hit.transform.parent = transform; 
   hit.rigidbody.isKinematic = true; 
   hit.rigidbody.useGravity = false; 
   hit.rigidbody.position=transform.position;

}

The second object is a simple cube with a Character Controller and a rigidbody (the iphone version) , now i want to run with the cube on the platform to elevate (lift) the cube (player), but the parent is changed and the cube dont follow the platform.

what is the mistake, maybe the caractercontroller, i dont know, i only want to move with the platform like in the 2D Demo.

Why is the player not following on the moving platform, i can jump on the base
if i walk a round while moving (the platform is lifting) it works, but if i dont, i fall. When the player stand on the moving base, while she is down moving it works.

You need to make sure that you have checked in your collider the “Trigger” option., and be aware, that if you use triggers, objects are going to be intersected :slight_smile:

maybe you are looking for OnCollisionEnter() function ?

Hope it helps :smile:

hi

i have tested it with an collision as follow.

The MP (MovingPlatform) ->Box Collider->Rigidbody → script

script of the MP

function OnCollisionEnter (hit : Collision)
{
   Debug.Log("Collision");
   hit.transform.parent = transform; 
   hit.rigidbody.isKinematic = true; 
   hit.rigidbody.useGravity = false; 

}

but if i walk withe the Player on the MP, no collision is triggerd, no log is written.

Checkout that both objects need to be rigidbodies

This is the setup i have:

The Moving Base:

The Player (little Cube)



Ok, I think I got it :stuck_out_tongue:

Checkout that your player is kinematic, this means that is not affected by physics, try to deactivate it and use gravity on the player then you should see the Collision log.

That not work,

i have done a Collision on the Player by changeing following on the player

function OnControllerColliderHit (hit : ControllerColliderHit)
 
{ 
	Debug.Log("Collision");


}

But the collision on the Platform dont work

function Update () {
}

function OnCollisionEnter (hit : Collision)
 
{ 
	Debug.Log("Collision on The BOX");
  

}

Is it possible that i allso must use a different function to check a collision between a Character Controler and a rigibody?

No that I know of :S.

lets you know if the character is touching ground :s
and the other function you have just posted are the ones that manage collisions…

The Player is grounded. Tells me the Console if i add this into the update function.

On the move platform if i disable is Kinematic property it fire´s up the collision event, so if i step on the MP and isKinematic is disabled it will flip