Character Move ON Platform

I have seen this many times but none have worked for me. I have a character controller on a sphere. I have a platform moving to the left and right. But the character controller always slips through it. Any Help

If you’re unfamiliar with OnControllerColliderHit, try searching it in the scripting reference section. You can also look up other question’s as I did to see examples of how to collect information about an object contacted with this. If you make a requirement for a collisionflags.below and a certain tag you can set the parameters for parenting whatever collider is being contacted by the controller. The parenting can be removed as soon as there is a collisionflags.none.

Umm in new to javascript for unity. Could you possibly write a little of the script to help me?

The following need’s to be in a script attached to the object you have the CharacterController attached to:
Also, you have to add a new tag named “Platform”(exact spelling and capitolization).

function OnControllerColliderHit (hit : ControllerColliderHit )
{
   if((hit.gameObject.tag == "Platform")(controller.collisionFlags  CollisionFlags.Below))
   {
    transform.parent = hit.gameObject.transform;
   }
}

This will cause your character to get “stuck” to the platform. I won’t give you more info yet because understanding what the collisionflags, and parenting is doing is what you need to understand first. It has to “click” for you, and that can only happen if you spend lots of time with it. Also, when you’re character get’s parented to the platform, any stretching and rotating will also be applied. I still haven’t fully grasped how that aspect works but I know if the platform’s scale ratio is always even( if x = 3, y and z = 3), then the character doesn’t get stretched oddly.