Sliding Pixel Collision?

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.
User avatar
kicknbritt
Citizen
Posts: 80
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

Sliding Pixel Collision?

Post by kicknbritt »

Hey guys. I am putting the finishing touches on my games terrain collision system and I need some help.
Here is the situation:
Imagine a bunch of players with an x, y and direction running around a map.
The map consists of a texture holding terrain pixels.

For collision detection, I am using the players x and y to check if a specific position contains terrain.
Players can move around and collide with terrain but upon hitting a wall they just sort of freeze :( (they get stuck on pixels).

I need a way to make player-wall collision cause them to slide along terrain.
Does anyone know of any way to do this?
Attachments
debug help3.png
debug help3.png (3.63 KiB) Viewed 5545 times
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
User avatar
darkfrei
Party member
Posts: 439
Joined: Sat Feb 08, 2020 11:09 pm

Re: Sliding Pixel Collision?

Post by darkfrei »

Not exactly what you want, but must be pretty close example:

Code: Select all

if angled_floor () then -- the floor is a ramp 45 or -45 degrees
	local sign = vx < 0 and -1 or 1 -- right moving gives positive value, left moving gives negative
	local t = tangent_of_ramp () -- gives 1 for 45 degrees and -1 for -45 degrees
	-- note that dy is inverted
	vy = sign*(-t)*vx -- vertical speed is the same as horizontal speed, but negative when the ramp has bottomleft-topright inclination.
end
Left tiles are "walkable", right tiles are "not walkable", but you can go through the bevels.
Attachments
tiles_32.png
tiles_32.png (976 Bytes) Viewed 5509 times
:awesome: Falling in LÖVE :awesome:
I Löve Lua and Love2D
User avatar
kicknbritt
Citizen
Posts: 80
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

Re: Sliding Pixel Collision?

Post by kicknbritt »

Sorry, maybe I should have specified the perspective is top-down.

I have tried to think of something but I can't find any way this would map directly to a top-down map but I could easily be wrong.
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
User avatar
ReFreezed
Party member
Posts: 323
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Sliding Pixel Collision?

Post by ReFreezed »

Before the game begins, calculate which corners should have slopes over them and put a "wedge" object or something there, and when players intersect with a wedge just handle the collision the same way as for axis-aligned walls, just at an angle.
Tools: Hot Particles, LuaPreprocess, (more) Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."
User avatar
kicknbritt
Citizen
Posts: 80
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

Re: Sliding Pixel Collision?

Post by kicknbritt »

Actually I was just thinking that. Trying to work something out right now
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
User avatar
kicknbritt
Citizen
Posts: 80
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

Re: Sliding Pixel Collision?

Post by kicknbritt »

I don't think that approach will work either because I need the player to slide on terrain in the direction they are moving.
Also I would rather find a way without precomputing everything if possible.

I guess what I really need, is some kind of math that determines a movement direction upon collision.
Or maybe I can just cast rays upon collision and sort of octopus players around terrain. This might be expensive though...
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
User avatar
ReFreezed
Party member
Posts: 323
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Sliding Pixel Collision?

Post by ReFreezed »

Is this the functionality you want?
SmoothCornerCollisionsInTiledTopDownGame.love
(2.31 KiB) Downloaded 122 times
Tools: Hot Particles, LuaPreprocess, (more) Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."
User avatar
kicknbritt
Citizen
Posts: 80
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

Re: Sliding Pixel Collision?

Post by kicknbritt »

Actually this might work. I think I misunderstood what you meant. Let me try to work in some sort of angular movement into the example.
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
User avatar
darkfrei
Party member
Posts: 439
Joined: Sat Feb 08, 2020 11:09 pm

Re: Sliding Pixel Collision?

Post by darkfrei »

Youtube has very nice suggestions!
https://youtu.be/Isvs9OzX6Lk

:awesome: Falling in LÖVE :awesome:
I Löve Lua and Love2D
User avatar
kicknbritt
Citizen
Posts: 80
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

Re: Sliding Pixel Collision?

Post by kicknbritt »

Sorry guys I have been insanely, insanely busy. I will try to get this worked on in a day or two.
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
Post Reply

Who is online

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