Well if it is a tiled map we can also modulo it to the wall and get away without advanced math.
But we could then fall though the floor if the fps drop.
Its always a tiny detail
I just wrote a game where i botched up exactly that checking and the result is that i can walk on the ceiling too, but i freaking love this bug, i should make a proper one with that mechanic.
Diagonal RPG Collission!!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- BrotSagtMist
- Party member
- Posts: 664
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Diagonal RPG Collission!!
Ahh, well: my map is tiled, so far im just using square tiles and marking them as solid or nonsolid. I'm just moving my character by 1 pixel at a time (looping for speed tho).
An answer I got was:
"the general way this is done is when your character collides with a wall you subtract the difference of how much they did move from how much they would have moved from their velocity
then you adjust their velocity vector to be parallel with the wall
this will make them slide along it"
and i could add velocity but would that work or would I have to change how im doing things??
An answer I got was:
"the general way this is done is when your character collides with a wall you subtract the difference of how much they did move from how much they would have moved from their velocity
then you adjust their velocity vector to be parallel with the wall
this will make them slide along it"
and i could add velocity but would that work or would I have to change how im doing things??
- BrotSagtMist
- Party member
- Posts: 664
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Diagonal RPG Collission!!
Again you havnt answered:
What is your collider code?
Also that quote is pretty mixed up, as in, does that even match the question?
Top down RPG, you should not have velocity or sliding and all that.
What is your collider code?
Also that quote is pretty mixed up, as in, does that even match the question?
Top down RPG, you should not have velocity or sliding and all that.
obey
Re: Diagonal RPG Collission!!
Ahh, makes sense.. im just literally checking the corners of my sprite, against the solid map tiles and preventing movement if it's solid anywhere.
- BrotSagtMist
- Party member
- Posts: 664
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Diagonal RPG Collission!!
I have still no idea what you do there, you seem to be lost in something complicated.
Just saying on an rpg movement the whole process is just:
So in total maybe 8 lines with all directions.
Just saying on an rpg movement the whole process is just:
Code: Select all
--for moving say left
if love.keyboard.isDown("left") then x=x-Speed*dt end
--for collid checking
if Map[math.floor(x/Tilesize-Spritesize)][math.floor(y/Tilesize)] then --revert to last point end
obey
Re: Diagonal RPG Collission!!
yea, that's what I'm doing, except I can't just keep referencing map[x][y] because some tiles are diagonal, half-solid, and i want to smoothly walk along them
Re: Diagonal RPG Collission!!
There is two main mechanics:
1. Step safe:
Code: Select all
local dx, dy = getMovementInputs ()
dx = dx * speed * dt
dy = dy * speed * dt
if canMove (player, dx, dy) then
doMovement (player, dx, dy)
end
2. Push back:
Code: Select all
local dx, dy = getMovementInputs ()
dx = dx * speed * dt
dy = dy * speed * dt
doMovement (player, dx, dy)
pushBack (player)
- BrotSagtMist
- Party member
- Posts: 664
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Diagonal RPG Collission!!
I now get it.
Youre working with a free map, not with tiles.
All this comments above where written under the impression your map has squared elements.
If your elements are triangles of course this will be a lot of more work.and normally takes a complete different approach.
But you can maybe get away with setting your movement code within the map:
map[x][y]()
That way you can have adjusted movements depending of where you step on.
obey
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests