Diagonal RPG Collission!!

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.
Krynn-San
Prole
Posts: 6
Joined: Tue Jun 20, 2023 6:49 am

Diagonal RPG Collission!!

Post by Krynn-San »

Hey, so I'm making a top-down rpg and i want smooth diagonal collision, as seen in A Link to the Past, or any similar rpg game tbh.

I've heard that the best way was using a velocity and subtracting how much you moved from how much you would have moved, but i dont rlly understand that, I cant find any tutorials, plus I'm moving my character by a speed, and looping for each pixel, and not even using a velocity.

So I was wondering: could I just mark diagonal tiles as similar to solid, but give them individual physics, based on the diagonal type and your direction?? Or would my best bet just be adding velocity?

Thanks in advance if anyone sees this!!
User avatar
BrotSagtMist
Party member
Posts: 636
Joined: Fri Aug 06, 2021 10:30 pm

Re: Diagonal RPG Collission!!

Post by BrotSagtMist »

What is your collider code anyway?
How is your map structured? Tiled, free?
obey
pauljessup
Party member
Posts: 356
Joined: Wed Jul 03, 2013 4:06 am

Re: Diagonal RPG Collission!!

Post by pauljessup »

Velocity is a fancy word for speed, basically, lol.
User avatar
UnixRoot
Citizen
Posts: 91
Joined: Mon Nov 08, 2021 8:10 am

Re: Diagonal RPG Collission!!

Post by UnixRoot »

pauljessup wrote: Wed Jun 21, 2023 1:09 am Velocity is a fancy word for speed, basically, lol.
Speed is the time rate at which an object is moving along a path, while velocity is the rate and direction of an object's movement. It's not the same, velocity is a vector.
pauljessup
Party member
Posts: 356
Joined: Wed Jul 03, 2013 4:06 am

Re: Diagonal RPG Collission!!

Post by pauljessup »

I was making a joke, that's all, riffing on the literal dictionary definition of velocity

Either way, I don't think you need velocity to do diagonal movement and diagonal collision, you just need to check both future x and y and not just one or the other...
User avatar
BrotSagtMist
Party member
Posts: 636
Joined: Fri Aug 06, 2021 10:30 pm

Re: Diagonal RPG Collission!!

Post by BrotSagtMist »

yee the usual way is just saving the position to a temp value, apply the movement, check if we are in a wall, and if we are just revert to the save.
obey
User avatar
Bobble68
Party member
Posts: 161
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: Diagonal RPG Collission!!

Post by Bobble68 »

BrotSagtMist wrote: Wed Jun 21, 2023 6:47 pm yee the usual way is just saving the position to a temp value, apply the movement, check if we are in a wall, and if we are just revert to the save.
This approach does work, though it does mean you'll never be right up against the wall, and means you sort of 'stick' to the wall so you can't slide against it when moving at an angle into it.
A more advanced approach is to move the player to a position on the line of movement that is exactly against the surface of the wall, that way you get right up close to the wall. (Granted, this version only solves the first issue)
Dragon
User avatar
darkfrei
Party member
Posts: 1186
Joined: Sat Feb 08, 2020 11:09 pm

Re: Diagonal RPG Collission!!

Post by darkfrei »

I am using the system:
Check the movement. If ok, then do the movement else don't do the movement. It's very universal and simple for realization.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
BrotSagtMist
Party member
Posts: 636
Joined: Fri Aug 06, 2021 10:30 pm

Re: Diagonal RPG Collission!!

Post by BrotSagtMist »

Yee, it works fine for rpgs, but bobble has a point, any physics simulation with gravity and you get a weird floating motion above obstacles :D
Then well need our freaking movement vectors.
obey
pauljessup
Party member
Posts: 356
Joined: Wed Jul 03, 2013 4:06 am

Re: Diagonal RPG Collission!!

Post by pauljessup »

Okay, yeah, that's true. For not sticking on walls movement vectors are hella important
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests