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

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3907 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.