Page 1 of 1

Check if the player is grounded code with bump.lua

Posted: Sat May 28, 2016 1:51 am
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

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

Posted: Sat May 28, 2016 6:10 am
by Davidobot
Crono wrote:..
Try checking if the normal is 1 instead or 0, one of those should work, I think.

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

Posted: Sat May 28, 2016 3:45 pm
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.

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

Posted: Sat May 28, 2016 4:40 pm
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.

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

Posted: Sat May 28, 2016 5:07 pm
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.