Check if the player is grounded code with bump.lua

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
Crono
Prole
Posts: 5
Joined: Mon May 09, 2016 4:35 am

Check if the player is grounded code with bump.lua

Post by Crono »

Beginner here. I'm trying to get the values of normal.y in the table cols in bump, to then change the variable self.onGround, but I just can't do that. Either the code is wrong or the logic is, but I don't know why. This is the code I think was supposed to work:

Code: Select all

for i=1, len do
	if cols[i].normal.y == -1 then
		self.onGround = true
		end
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Check if the player is grounded code with bump.lua

Post by Davidobot »

Crono wrote:..
Try checking if the normal is 1 instead or 0, one of those should work, I think.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
Crono
Prole
Posts: 5
Joined: Mon May 09, 2016 4:35 am

Re: Check if the player is grounded code with bump.lua

Post by Crono »

Davidobot wrote:
Crono wrote:..
Try checking if the normal is 1 instead or 0, one of those should work, I think.
If I do that the variable never gets true.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Check if the player is grounded code with bump.lua

Post by Davidobot »

Crono wrote: If I do that the variable never gets true.
Is the variable ever true when you check for -1?
If anything you can just check if there is a block 1 px under the player.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
Crono
Prole
Posts: 5
Joined: Mon May 09, 2016 4:35 am

Re: Check if the player is grounded code with bump.lua

Post by Crono »

Davidobot wrote:
Crono wrote: If I do that the variable never gets true.
Is the variable ever true when you check for -1?
If anything you can just check if there is a block 1 px under the player.
I had the code for this and I remember that the value was -1, but I deleted it because I'm and idiot. I'm already using the 1 pixel for now.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests