Problems with jumping off from a moving platform

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Problems with jumping off from a moving platform

Post by pacman »

I made a moving platform. 16x16.
Player collide with platform when his legs are on top or inside the platform. If so, player.y is lifted up if necessary.
Now, when the platform is moving right there is no problem with jumping off from the left side.
If you try to do that from right side the collision will hunt you down next frame and put you on top.
Is this a common problem or am I doing something very wrong?
I don't know if making 1 pixel collision is safe - I don't want to fly through it.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Problems with jumping off from a moving platform

Post by Jasoco »

We can't do anything without an example .love.
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Re: Problems with jumping off from a moving platform

Post by pacman »

I didn't want to post love file because I would need to prepare it and the problem wasn't in code but in lack of idea :?
At the end of the day there are 3 points that can collide

Code: Select all

  .     .     .
[][][][][][][][][]
Points on the edges will collide only when they are on the very same pixel as the platform. So If I fall down by 0.0000001 it won't let me back to the top.
Point in the center collide with whole platform so you can clip on top :3

I wonder if there is a way to know how games where made in the ~NES era. They probably couldn't get messy with the code so everything was slick. Would be cool to see something like Mario getting break down to smallest problems.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Problems with jumping off from a moving platform

Post by micha »

I would like to help, but I find it difficult to understand what the problem is you are facing. If you could upload a .love, that would say more than 1000 words.

And, in case you are not aware of this overview, check this out: Guide to implementing 2d platformers
User avatar
zorfmorf
Prole
Posts: 35
Joined: Sat Mar 10, 2012 12:31 pm

Re: Problems with jumping off from a moving platform

Post by zorfmorf »

Without your code and just your description I'd say that your problem is that you let your player move/fall anywhere and If you discover that he is on an invalid position you adjust his position. That's generally not what you want to do as judging how to fix an invalid position is not easy (as you just noticed yourself) because you'd need to know where the player was before.
Instead, before you move the player by dt, check where he is going to end up, check if that position (or any positions inbetween) is invalid and only move as far as possible into that direction. Your moving platform itself then just needs to check if it collides with the player when moving to the side and push the player along x axis.
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Re: Problems with jumping off from a moving platform

Post by pacman »

Yeeee I had few silly problems. One is that I first moved platform and then checked if player is standing on it, instead of first checking collisions and then move either platform or player+platform. There were frames where platform jumped on next pixel lefting player behind causing jerky movement/falling down.
Second problem was with drawing. I thought moving player with same velocity as platform will be good enough.
If
platform.x = 1.2 and
player.x = 1.8
they are displaying on the same pixel. After few frames let's say platform will move by 0.3, then
platform.x = 1.5
player.x = 2.1
aaaaaaaand the player goes one pixel off. Again - jerky movement.
Now I'm not platform virgin.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 202 guests