- Home /
Make a Platform push a character controller?
Hi, I'm looking for a way to make an object with a collider attached be able to "push" a character controller along without the controller just sliding through it. This is mostly for moving platforms and the like.
Getting a character to stand ontop of a platform and move along with it is fairly easy; my problem is when the platform floats horizontally into the character controller and just "passes" right through him. I can't use OnControllerColliderHit because if the controller isn't moving then it doesn't register the collision...kinda lost here, would appreciate any kind of solution for this or direction I could go to accomplish it.
Thanks you for any help.
Answer by spinaljack · May 22, 2010 at 01:34 AM
This question has been answered already if you take a look at the search function.
You want to test for collision with the character controller and then edit the character's transform.position directly with the relative position of the moving platform.
How would I test collision with the controller if he's not moving (ie: the controller is static and the platform is floating horizontally into him) because OnControllerColliderHit only triggers when the character is moving...or is there another way to check it?
Thanks for the answer
You can place a trigger all around your moving platform with a rigid body (either the platform or the character needs one for collision to be detected) and use OnTriggerStay to perform your logic.
Also, no collisions are detected on a rigid body that's sleeping so you might want to call Awake() on it to make sure it's no sleeping
Answer by carlos.castaneda · Jan 22, 2013 at 05:26 AM
In platform-character behavior I prefer to parent the player to the platform, this allow to inherit the translational movement of the platform to the player and even allow the player to move and jump above the platform without any problem.
the platform must have a collider and a trigger (the trigger should have the parenting script)
Your answer
Follow this Question
Related Questions
What is the easiest way to push a character controller with a moving platform? 0 Answers
Keeping the player on a moving platform? 0 Answers
CharacterController falls through or slips off moving platforms 2.0 2 Answers
moving platform jumping and then continuing it's path 0 Answers
Problem with moving (animated) platforms. need script to keep player object on 1 Answer