Need help with collision detection issue

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
ChrisTorp
Prole
Posts: 2
Joined: Wed Jan 23, 2013 6:36 am
Location: Norway
Contact:

Need help with collision detection issue

Post 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. ^^
Attachments
gravitytest.love
(1.2 KiB) Downloaded 125 times
- Chris
User avatar
Saegor
Party member
Posts: 119
Joined: Thu Nov 08, 2012 9:26 am
Location: Charleroi

Re: Need help with collision detection issue

Post 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
Attachments
gravitytest2.love
(1.11 KiB) Downloaded 116 times
Current work : Isömap
ChrisTorp
Prole
Posts: 2
Joined: Wed Jan 23, 2013 6:36 am
Location: Norway
Contact:

Re: Need help with collision detection issue

Post 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?
- Chris
Post Reply

Who is online

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