iOS – Sprite Kit collision without bounce

I set up a hero and some platforms that move down from the top.
With these, I have collisionBitMasks, which can detect when the hero has landed on the platform, and if the hero comes from above ( Let the hero jump over the platform)

if (_hero.physicsBody.velocity.dy> 0) {
_hero.physicsBody.collisionBitMask = 0;
}
else {_hero.physicsBody.collisionBitMask = platformCategory;
}

Everything is fine, except that the hero bounces on the platform.
When the platform moves down , Is there a way to let him sit on it?

I tried to use physicsBody.resting and physicsBody.friction, but no success.

Thank you for your help

I had the same problem a minute ago. It is suitable for setting reverts, but you need to set two reverts. Heroes and one of the platforms (or in my case Is the scene boundary).

So:

hero.physicsBody.collisionBitMask = platformCategory
hero.physicsBody.restitution = 0.0< br />platform.physicsBody.restitution = 0.0
any_other_object_that_should_still_bounce.physicsBody.restitution = 1.0

Will do it. As long as you set it back to its original state, all other objects on the screen will still bounce on the platform . 0

I set up a hero and some platforms that move down from the top.
With these, I have collisionBitMasks, which can detect when the hero has landed on the platform , If the hero is from above (let the hero jump over the platform)

if (_hero.physicsBody.velocity.dy> 0) {
_hero.physicsBody. collisionBitMask = 0;
}
else {_hero.physicsBody.collisionBitMask = platformCategory;
}

Everything is fine, except that the hero bounces on the platform.
When the platform moves down, is there a way to let him sit on it?

I tried to use physicsBody.resting and physicsBody.friction, but no success.

Thank you for your help

< p>There was the same problem a minute ago. It is suitable for setting reverts, but you need to set two reverts. Hero and one of the platforms (or scene boundary in my case).

So:

hero.physicsBody.collisionBitMask = platformCategory
hero.physicsBody.restitution = 0.0
platform.physicsBody.restitution = 0.0
any_other_object_that_should_still_bounce.physicsBody.restitution = 1.0

Will do it. As long as your settings are restored, all other objects on the screen will still bounce on the platform. 0

Leave a Comment

Your email address will not be published.