- Home /
How to compensate for moving platforms that move side to side
I followed the exact way that was described in the link. It works great with vertical moving platforms. However, when I got my character to a platform that was moving side to side, the character didn't move with the platform. Is their a way to compensate for this?
Answer by Deo · May 21, 2010 at 01:18 AM
I got the simplest solution for this problem from another forum.
So basically, you create another object with collider on top of your normal platform, and parent it to your platform.
Apply this script to your collider object, and it should work.
function OnTriggerEnter (other : Collider) { other.transform.parent = gameObject.transform; } function OnTriggerExit (other : Collider) { other.transform.parent = null; }
Sorry for the late response, but I tried that and it just makes my character fall through the platform.
Ok I did something wrong. It works now but the problem I have is that when my player turns around, he just randomly disappears and the Character Controller keeps changing in size. What's going on?
Answer by jamesster · Sep 27, 2010 at 09:33 PM
Create an empty GameObject. Add a mesh collider in the shape of your platform, and make it a trigger. Then make it a child of your platform/elevator (it works for both), and raise it so it is just a little higher then the platform itself. Then attach this script to the trigger you made:
var Player : Transform; var Elevator : Transform;
function OnTriggerEnter (other : Collider) { Player.parent = Elevator; }
function OnTriggerExit (other : Collider) { transform.DetachChildren(); }
Make the trigger GameObject in the Elevator slot and your player in the Player slot. When your player gets on the moving platform, he/she will not slide off and will move with the platform perfectly in any direction.
my question was the same, and i tried this answer, but! my character moves with the platform (i have rotating platforms) even when in the air!!! any ideas?
I'm having the same issue and it didn't work at all. The player still slides off. I've tried many methods. Putting a CharacterController on it and messed with some methods that included that, messed with the Trigger method, and different versions of the parenting method. Nothing's working.
Just to make sure I wasn't too confusing when I said "it", the CharacterController was put on the player not the platform.
I'm also having this issue. It's a real pain and cannot figure out how to make this smooth connection between moving platforms and the player.
Nice, but my character slightly follows the motion of the platform. the player still falls off, but follows the platform as it moves very slightly. Is there a reason for this?
Your answer
Follow this Question
Related Questions
Moving Platforms + Third Person Controller 0 Answers
Moving an object between two positions (C#) 1 Answer
How to make character "stick" to moving platform? 2 Answers
Broken animations 1 Answer
2D Platformer Moving Platform Question 3 Answers