Help with platformer

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
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Help with platformer

Post by Vimm »

So I'm working on some platform collisions, and I have the collision for the top of the platform down, but the way I have it, when my player collides with the side, he just pops back up to the top. I know I had a fix for this a little while back, but I've completely forgotten it :/ can someone offer some insight?
Attachments
Platform.love
(1.21 KiB) Downloaded 64 times
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: Help with platformer

Post by Sulunia »

I have no experience in platformer games, but i recommend you to keep your code commented. It makes others lives much easier since they'll know what a specific session does.

I messed a bit with your code. Sometimes pressing D and A often makes your character jump, for some reason.
Printing the value of "player.isFalling" actually shed a light on this. The value keeps bouncing between true and false. I "fixed" this here, but the character wouldn't jump anymore, so, i guess it's back to square zero.
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: Help with platformer

Post by Vimm »

Sulunia wrote:I have no experience in platformer games, but i recommend you to keep your code commented. It makes others lives much easier since they'll know what a specific session does.

I messed a bit with your code. Sometimes pressing D and A often makes your character jump, for some reason.
Printing the value of "player.isFalling" actually shed a light on this. The value keeps bouncing between true and false. I "fixed" this here, but the character wouldn't jump anymore, so, i guess it's back to square zero.
yeah I noticed the character would jump when changing directions, which is weird since he should only jump when hitting one of the jump keys.

And you're right, I should comment my code,but I barely understand what it does myself ;)

Yeah player.isFalling switches between true and false because I set player to be one pixel above the platform when he touches it, cuz if I didn't he'd sometimes get stuck, it was a temporary fix that seemed to cause more problems
User avatar
Sulunia
Party member
Posts: 203
Joined: Tue Mar 22, 2016 1:10 pm
Location: SRS, Brazil

Re: Help with platformer

Post by Sulunia »

In that case, make sure isFalling value does not bounce around, and make sure that the character only jumps when the JUMP key is pressed, rather than checking if he's falling to modify his Y speed. I'm not looking into code right now since it's damn late here, but if you keep on having problems i'll help you out tomorrow.
Don't check my github! It contains thousands of lines of spaghetti code in many different languages cool software! :neko:
https://github.com/Sulunia
User avatar
Vimm
Party member
Posts: 113
Joined: Wed Mar 16, 2016 8:14 pm

Re: Help with platformer

Post by Vimm »

Sulunia wrote:In that case, make sure isFalling value does not bounce around, and make sure that the character only jumps when the JUMP key is pressed, rather than checking if he's falling to modify his Y speed. I'm not looking into code right now since it's damn late here, but if you keep on having problems i'll help you out tomorrow.
I managed to fix some stuff, but now when player collides with the left or right of the platform, he cant move left or right, also, if he gets to the edge of the platform, movement gets buggy, i kinda know what causes this(setting xVel = 0) but idk how to fix it
Attachments
PlatformV2.love
(1.27 KiB) Downloaded 57 times
User avatar
4aiman
Party member
Posts: 262
Joined: Sat Jan 16, 2016 10:30 am

Re: Help with platformer

Post by 4aiman »

Why not to use Bump?
It will help you to go past the point where you are detecting collisions and move on to deciding what do you want to do with the objects around collisions. :)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 44 guests