Page 1 of 1

Need help with collision detection issue

Posted: Wed Jan 23, 2013 6:50 pm
by ChrisTorp
Hey, first time writing here, but I'll try to be as thorough as I can.
I'm just starting to learn coding, so I'm always trying out things and practicing things, following tutorials and such.
So I tried following this tutorial about physics and world callbacks, and I think I got it, but I, being a beginner after all wanted to extend on it, so I started adding walls and blocks and such.

Now here is where my issue begins. Everything seems to work fine, except whenever the player ends up in a corner the jumping is disabled. And yes, I have states so the player can only use jump when on the ground (or platform). And I have turned off jumping when jumping and sliding down the wall. But even when I didn't have jumping on wall disabled, the wall would always disable the collision with the ground.

I guess I typed a little more than necessary as the end seems to pretty much sum it up. The wall disables the ground collision when in corner.

Any solution? :megagrin:

Oh, also, I might add, you can use either Xbox 360 controller or keyboard to move.

Controller:
Hold X : Move faster
A : Jump
Left stick to move

Keyboard:
Left & Right arrow keys to move
Hold lshift : Move faster
Space : Jump

Thanks in advance. ^^

Re: Need help with collision detection issue

Posted: Thu Jan 24, 2013 8:57 pm
by Saegor
it seems it's a presolve() problem (but i'm a TOTAL noob at physics)

i putted that instead of your beginCollision()

Code: Select all

	local x, y = coll:getNormal()
	text = a:getUserData() .. " is touching " .. b:getUserData() .. " at " .. x .. ", " .. y
	
	if a:getUserData() == "Down"
	or a:getUserData() == "Right"
	or a:getUserData() == "Block"
	or a:getUserData() == "Block2"	then

		jumpEnabled = true
	end
and emptied your presolve() and it works fine
sorry for the english, test the love (i renamed some things shorter)

EDIT you must erase the line i add

Code: Select all

	or a:getUserData() == "Right"
cause it make no sense

Re: Need help with collision detection issue

Posted: Fri Jan 25, 2013 9:40 am
by ChrisTorp
It did help with the issue when jumping while pressed against the wall, and also sliding down from wall to ground and jumping up again. But the collision to the ground still disappears if you just walk into the corner and out again without jumping.

Is there a better, yet somewhat easy way to do the jumping?

Oh, I like what you did to the coding btw, looks a lot cleaner, thanks. ^^

EDIT: Is there maybe a way to make it look for a new collision when ending a collision? Like, forcing it to check if there is another collision?