- Home /
Problem with moving (animated) platforms. need script to keep player object on
ok so i have a platform which is actually an airship animated into my game. the ship is a rigid body, and has colliders set so it's a solid object.
i can jump on it with the player and move around it while the ship is STATIONARY, but when the animation starts to move the ship the player does not move with the ship, and will after a second fall through the ship. i can stay on the ship if i keep the player constantly moving.... but not standing on the ship.
i've seen a few parent / child scripts out there that claim to fix this but nothign has worked so far for me.
is anyone able to help me out with this? thanks
Answer by cregox · Mar 29, 2011 at 08:40 PM
Parenting your player on the ship is a very good solution. Here's an instance I've used in a real case:
function Update () {
transform.parent = GetGroundTransform();
}
The GetGroundTransform
method will depend on your character controller implementation. In this instance it should return a transform
with the ground object or null if none.
Your answer
Follow this Question
Related Questions
Stay on Moving Platform without Character Controller 1 Answer
Keeping the player on a moving platform? 0 Answers
Rigidbody on a moving platform 6 Answers