Jumping through platforms& landing on top, only when bottom of player collides with top of platform?

Hi!

I have a game where the player moves up, jumping through and on top of platforms. I have a code set up for the player that changes its velocity upwards when its moving down and overlaps/collides with the platform:

If attribute self.motion.linear velocity.Y > 0, then change attribute game.Moving up? to True, otherwise change attribute game.Moving up? to False

If attribute game.Moving up? is false and if actor overlaps or collides with platform, change velocity (direction 90, speed 800 relative to scene)

So when I have the code set up like this, if the top of the player collides with the bottom of the platform its velocity changes. I want the velocity to change only when the bottom of the actor collides with the top of the platform.

I've tried a lot of tutorials but when I add the change velocity behavior it doesn't work!

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Try putting a rule around your logic that only changes velocity when the character is higher than the platform, you'd have to take into account that the x and y position is at the centre of your character so it would be something like this:

    if (character.y > platform.y + (character.size.height / 2) and collision detected) then change your velocity
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Just realised that you'll have to add half of the platform height to that sum as well otherwise it will change velocity when it collides with the middle of the platform
Sign In or Register to comment.