- Home /
Moving a player on a rigidbody platform that can collide
Hey guys I know this question has been asked a lot but I can't seem to find an answer that works for me.
So what im looking to create is a game where the player can move around on a moving platform where the platform can collide with other platforms or terrain. So i made a non kinematic rigid-body and started moving it around with forces which works great when colliding with other objects but I couldn't get my player to be able to stand on the object and move with it. I tried having my player be a character controller and parent the player to the platform but for some reason it still gets shaken off. Then i tried a more physics based way where the platform had high friction and a rigid-body on the player which kind of worked but the player would move really slowly in one direction and fast in the other and just be generally awkward to move around. I then started moving the player and platform with rigidbody.MovePosition which worked great but the platform wouldn't collide with other objects. I think this may be the right way to do it but I cant get collisions working how I would like. I feel like I've tried all the combinations but I cant seem to get it. If someone could help in this situation I would be very appreciative.
Not sure how to do this, but maybe a tip to try. The players movements are generally global units. $$anonymous$$aybe you can set the player movements relative to the moving object ins$$anonymous$$d of global. Or by doing a check to see if the player is on this moving object, and if so, the current position of your player would be his transform updated by adding the transform of the moving object.
Let's say the object is a magic carpet. Store the transform of the magic carpet in something like currentCarpetPosition (Vector3) and add that to the player object's transform.position. transform.position (Player transform) = transform.position + currentCarpetPosition. I feel like that would work but their may be something else necessary. Good luck!
This is the exact same problem that I have :L
Does anyone have a good answer for this? :(
Answer by RobAnthem · Dec 08, 2016 at 06:46 AM
You can create psuedogravity and make your floating object the gravity well and have a script on the player to move him to your psuedogravity.