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?
Sliding Pixel Collision?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- kicknbritt
- Citizen
- Posts: 96
- Joined: Sat May 30, 2015 2:15 am
- Location: Chicago, IL/Anchorage,AK
Sliding Pixel Collision?
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
Re: Sliding Pixel Collision?
Not exactly what you want, but must be pretty close example:
Left tiles are "walkable", right tiles are "not walkable", but you can go through the bevels.
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
- kicknbritt
- Citizen
- Posts: 96
- 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 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*
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."
"If each mistake being made is a new one, then progress is being made."
- kicknbritt
- Citizen
- Posts: 96
- 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: 96
- 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...
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*
Re: Sliding Pixel Collision?
Is this the functionality you want?
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
"If each mistake being made is a new one, then progress is being made."
- kicknbritt
- Citizen
- Posts: 96
- 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*
Re: Sliding Pixel Collision?
Last edited by darkfrei on Mon Feb 20, 2023 9:54 am, edited 2 times in total.
- kicknbritt
- Citizen
- Posts: 96
- 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: Ahrefs [Bot], Bing [Bot], Google [Bot] and 9 guests