Rigidbody on a moving platform

Hi.

I am currently redeveloping our character-controller based player into a rigidbody-based player for Pirates of New Horizons because we got some strange behaviors when switching to unity 3.x from 2.6.

We figured we would have more control if we did things ourselves.

However, I am struggling with having our player be moved by other rigidbodies. More specifically; moving platforms that are underneath the player. The player will be pushed sideways if something hits it from the side, or moved upwards if something underneath pushes upwards, but I cant seem to figure out how a platform moving in the x-z plane can move the player, which is a rigidbody, standing ontop of it.

On the old character controller I had implemented the solution that can be found here:
CharacterController falls through or slips off moving platforms - Unity Answers but since all the rigidbody movement is applied during FixedUpdate, this isn’t working so well.

Does anyone know how I can approach this problem without parenting to the stuff below, because that feels very jerky when I have tried it.

Just add script with this code to platform. Works like charm for me.

    void OnCollisionEnter2D(Collision2D other) {
        if (other.transform.tag == "Player") {
            other.transform.parent = transform;
        }
    }

    private void OnCollisionExit2D(Collision2D other) {
        if (other.transform.tag == "Player") {
            other.transform.parent = null;
        }
    }

I know this is an old thread, but I will answer here anyway, as I have been looking to do essentially the same thing for a while and finally figured it out.

I’ve been messing around with this for the better part of 3 months. I have a rigidbody WIHTOUT a character controller. I have a character that I need to be able to roll onto and off of moving platforms, so parenting wasn’t really an option, and the character controller didn’t really allow me to do some of the other things I have going on in the game. The answer I found was to create PhysicsMaterial like was mentioned above. I pretty much maxed out everything to do with friction (either 1, Maximum, or for open ended options, 100,000) and set bounciness to 0 or Min. Make sure to set the FrictionDirection2 in the X and Z axes again, (100,000). Then I added this PhysicsMaterial to the box collider on the platform, and finally, I added a rigidbody to the platform, set the mass at between 100 and 1000 (depending on how it plays) set the Rigidbody to “Is Kinimatic”, turned off gravity zeroed everything else out and then played with the velocity of the platform to keep the Character from tipping over. After 3 months, the real key here was adding the Rigidbody to the platform, without it nothing happens (and I have the mass of my Character set to 100,000 on it’s rigidbody, so a little platform mass goes a long way!) Good luck!

Moving the platform using only Rigidbody.MovePosition and Rigidbody.MoveRotation in FixedUpdate fixes slipping/bouncing and gives a very smooth and accurate simulation.

Check the full answer in this question: http://answers.unity3d.com/questions/167404/rigidbody-on-a-platform.html

Have you tried tweaking the PhysicMaterials you are using, and increasing the contact points (eg box not capsule), such that friction does the work for you? That’s the real-world answer to your question… not that game physics is perfect of course! Also be careful of the drag setting on the player RB. Also be careful how you move the platforms. Anyone will slip over if the floor beneath them accelerates from 0 to 1m/s in 0.01 seconds.

Hey Skjalg,
did you already found out how to make a player move fine on a moving object?
I’m also struggling with this.

Look everyone i tried the same. I use parenting to set my player to move it does but the weapons parented to player act very strangely being huge and out of controls. So i thought u guys may have somthin better in my game the player not only stand on moving platforms in x or z axis even i y as elevators so if anyone got answer pls share it.