Having trouble with bump when different objects are on the screen

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
MaxGamz
Party member
Posts: 104
Joined: Fri Oct 28, 2022 3:09 am

Having trouble with bump when different objects are on the screen

Post by MaxGamz »

I started following a tutorial for bump and for the most part everything was working smoothly; however, I am having some issues and glitches for when the player interacts with different objects. I've seen issues like this before where the player is unable to jump in bump or after it jumps onto another platform it is unable to fall off and just sort of glides there. My code doesn't have any of those issues, but the player glitches out once it is under the second object or jumps away from it. I am new to bump but I am getting a hang of it so hopefully I can figure out what is causing the issue.

Here is the file so it will be easier for you guys to understand and play around with.
Attachments
bump_test.love
(827.96 KiB) Downloaded 30 times
MrFariator
Party member
Posts: 525
Joined: Wed Oct 05, 2016 11:53 am

Re: Having trouble with bump when different objects are on the screen

Post by MrFariator »

You are experiencing this behavior because you are using the world:check function, as opposed to the world:move function.

Code: Select all

-- change this...
local actualX, actualY, cols, len = world:check(player, futureX, futureY)
-- to this
local actualX, actualY, cols, len = world:move(player, futureX, futureY)
As per bump.lua docs:
It (world:check) returns the position where item would end up, and the collisions it would encounter, should it attempt to move to goalX, goalY with the specified filter.
Notice that check has the same parameters and return values as move. The difference is that the former does not update the position of item in the world - you would have to call world:update in order to do that. In fact, world:move is implemented by calling world:check first, and then world:update immediately after.
If you use world:check without using world:update alongside it, you'll get this sort of jittery behavior where the movement can behave rather erratically. Generally, you'll be fine with just using world:move, unless you have a specific reason for world:check.
MaxGamz
Party member
Posts: 104
Joined: Fri Oct 28, 2022 3:09 am

Re: Having trouble with bump when different objects are on the screen

Post by MaxGamz »

MrFariator wrote: Sat Aug 26, 2023 2:25 pm You are experiencing this behavior because you are using the world:check function, as opposed to the world:move function.

Code: Select all

-- change this...
local actualX, actualY, cols, len = world:check(player, futureX, futureY)
-- to this
local actualX, actualY, cols, len = world:move(player, futureX, futureY)
As per bump.lua docs:
It (world:check) returns the position where item would end up, and the collisions it would encounter, should it attempt to move to goalX, goalY with the specified filter.
Notice that check has the same parameters and return values as move. The difference is that the former does not update the position of item in the world - you would have to call world:update in order to do that. In fact, world:move is implemented by calling world:check first, and then world:update immediately after.
If you use world:check without using world:update alongside it, you'll get this sort of jittery behavior where the movement can behave rather erratically. Generally, you'll be fine with just using world:move, unless you have a specific reason for world:check.
Thanks for the advice! I didn’t know there was a difference between the two functions
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest