## Sliding Pixel Collision?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
kicknbritt
Citizen
Posts: 95
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

### Sliding Pixel Collision?

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 (3.63 KiB) Viewed 7798 times
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
darkfrei
Party member
Posts: 874
Joined: Sat Feb 08, 2020 11:09 pm

### Re: Sliding Pixel Collision?

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 (976 Bytes) Viewed 7762 times
kicknbritt
Citizen
Posts: 95
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

### Re: Sliding Pixel Collision?

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*
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

### Re: Sliding Pixel Collision?

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, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
kicknbritt
Citizen
Posts: 95
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

### Re: Sliding Pixel Collision?

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

### Re: Sliding Pixel Collision?

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*
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

### Re: Sliding Pixel Collision?

Is this the functionality you want?
SmoothCornerCollisionsInTiledTopDownGame.love
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
kicknbritt
Citizen
Posts: 95
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

### Re: Sliding Pixel Collision?

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*
darkfrei
Party member
Posts: 874
Joined: Sat Feb 08, 2020 11:09 pm

### Re: Sliding Pixel Collision?

https://youtu.be/Isvs9OzX6Lk

kicknbritt
Citizen
Posts: 95
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

### Re: Sliding Pixel Collision?

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*

### Who is online

Users browsing this forum: No registered users and 83 guests