How to handle colissions on a big map

0 favourites
  • 4 posts
From the Asset Store
A template which allows you to customise the controls of your game.
  • I have a big room (1400,800) and i am trying to figure out how to do colissions properly ( it's a dungeon so there are a ton of walls) My room is one big sprite(i didn's use a tilemap because i know it's not good at having a lot of diffrent objects like scenery and also i would need something like 3 or 4 of them (because you have no layers on c2 tilemaps). So i have this big image with no colissions, so i just added an invisible tilemap , resized it to be as the room and started making the colissions manually. It works as intended except the fact that i get 4 million colission checks per second in the debugger and lag on mobile. I then instead used like 20 smaller tilemaps (because i read about colissions on the blog and how they are registered) and now it works well, but it's very tiring and takes way too much time. And that's just for one room, and i plan on building over 50. Is there a better way to do it? Or some way to split a big tilemap into 20 smaller ones?

  • so apparently it was not only the tilemap that caused the problem but also a lot of small object that i also had checking for colissions. since these objects don't move and could never collide with the tilemap anyways, is there a way of checking for colissions only between certain objects (so the player and the destroyables, but not the destroyables with the walls?

  • The system only checks for collisions when it's needed - if you have events "On collision" or "Is overlapping" or if there are behaviors on the objects that register collisions (platform, physics etc.)

    So normally your destroyables should not generate collisions check with the walls.

    You said your layout is (1400,800) - is this in pixels or is this the number of tiles on the tilemap?

    If in pixels, it's not that big and you should be able to use tilemap or even several tilemaps on top of each other.

    If you have lots of individual sprites like destroyables, you can disable/enable collision for them if they are too far from the character or in another room etc.

    System-> Pick by comparison-> Sprite where distance(Sprite.X, Sprite.Y, Character.X, Character.Y)<100 : Sprite Set collision enabled

    System-> Pick by comparison-> Sprite where distance(Sprite.X, Sprite.Y, Character.X, Character.Y)>=100 : Sprite Set collision disabled

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The system only checks for collisions when it's needed - if you have events "On collision" or "Is overlapping" or if there are behaviors on the objects that register collisions (platform, physics etc.)

    So normally your destroyables should not generate collisions check with the walls.

    You said your layout is (1400,800) - is this in pixels or is this the number of tiles on the tilemap?

    If in pixels, it's not that big and you should be able to use tilemap or even several tilemaps on top of each other.

    If you have lots of individual sprites like destroyables, you can disable/enable collision for them if they are too far from the character or in another room etc.

    System-> Pick by comparison-> Sprite where distance(Sprite.X, Sprite.Y, Character.X, Character.Y)<100 : Sprite Set collision enabled

    System-> Pick by comparison-> Sprite where distance(Sprite.X, Sprite.Y, Character.X, Character.Y)>=100 : Sprite Set collision disabled

    Thanks for the help. There is a very weird thing tho. Something must have went wrong in that project because i copy pasted the room, tilemap, destroyables and players from the other project to a new one, and no i only get a maximum of 40k colission checks, which is way better than 4 million. I didn't have any on colission or overlap events. Weird. I will use your tip anyways, i will aim for 60 fps even on older devices

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)