Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a Hero physics body to calmly rest on a moving platform physics body?

My game has a Ferris Wheel with 4 seats. Each seat has a platform that the hero can rest on. When the seat is on the upward trajectory the hero calmly stays on the platform.

However, when the seat is on the downward trajectory the Hero moves up/down a bit.

I've tried a few obvious things: 1. Setting the restitution to 0 has no effect. 2. Setting linearDamping to 1 has no effect. 3. Making the mass of the platform and hero the same has no effect. 4. Adjusting friction has no effect.

Here is the platform physics body:

        supportNode?.physicsBody?.categoryBitMask = PhysicsCategory.ferrisPlatform.rawValue
        supportNode?.physicsBody?.mass = 1000
        supportNode?.physicsBody?.restitution = 0.0
        supportNode?.physicsBody?.friction = 0.0
        supportNode?.physicsBody?.linearDamping = 1.0

Here is the hero body:

    self.physicsBody?.linearDamping = 1.0
    self.physicsBody?.mass = 30
    self.physicsBody?.restitution = 0
    self.physicsBody?.friction = 0

Thanks for any tips. Its definitely bizarre that the hero is fine on the way up on the ferris wheel ride but only shows quirky up/down movement on the way down.

like image 419
josh k Avatar asked Oct 30 '22 08:10

josh k


1 Answers

It seems like a problem of mass to me. The platform's mass has nothing to do with it because I read that it's pinned to the wheel. So you should increase the players's mass. If you go in a ferris wheel and make it spin fast enough, you will float too while going down. Setting restitution to 0 is good to avoid bounce, but it won't help keeping a light object in place: it's just not falling fast enough.

Also, you might want to actually increase the friction so the body won't slide. With 0 friction it's like sitting on ice.

like image 99
BadgerBadger Avatar answered Nov 15 '22 05:11

BadgerBadger