GameMaker Studio 2 Desktop

GameMaker Studio 2 Desktop

Greywolf Apr 5, 2018 @ 10:15am
Best way to handle collisions in a top down tile based RPG?
So yeah looking at a lot of tutorials and some use an invisible object laid over the top of the tileset to set their boundries while others put collision objects on a separate tile layer and handle the collisions based on what layer the tile is on, what would you guys recommend is the best method for creating boundries and defining walkable areas in a top down RPG?
< >
Showing 1-5 of 5 comments
maras Apr 5, 2018 @ 11:23am 
The easiest and the most efficient way:

if place_meeting(x+hspd, y, obj_wall)
{
while !place_meeting(x+sign(hspd), y, obj_wall)
{
x += sign(hspd);
}
hspd = 0;
}

if place_meeting(x+vspd, y, obj_wall)
{
while !place_meeting(x+sign(vspd), y, obj_wall)
{
x += sign(vspd);
}
vspd= 0;
}

y += vspd;
x += hspd;
Greywolf Apr 5, 2018 @ 5:03pm 
Yeah that is pretty similar to what I have at the moment, thing I am concerned with is what to put as the object that triggers the colision in the place_meeting() function, whether to put it as everything on a specific layer or as a separate object within the game world that defines the boundaries of where you can walk.

I take it by your example you recommend having a seperate invisible object laid over the tiles to handle collisions with the game world?
Uboa Apr 6, 2018 @ 1:31pm 
I'm not an expert or anything but I am in favor of tile-based collisions whenever possible because that way you don't need to have tons of collision objects in your rooms if you want large maps.
BananaGunBrian Apr 9, 2018 @ 11:24pm 
Does having tons of collision objects on its own layer slow down games tremendously?
Uboa Apr 10, 2018 @ 8:07am 
Sure seems like it to me. It's my understanding that even empty objects have some amount of processing load involved in keeping them active. One way to deal with this is to deactivate objects which are far away from the player and reactivate them when you come into range, but in my experience, activating objects has a big effect on performance as well so I try to keep it to the minimum that I can get away with.

You could try putting however many collision objects you'll need in a room and walking around in it to see if there's a performance hit, but keep in mind that any such slowdown might not be apparent until you have more of the logic-heavy objects in play as well.
Last edited by Uboa; Apr 10, 2018 @ 8:11am
< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: Apr 5, 2018 @ 10:15am
Posts: 5