• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code [SOLVED!] Automatically placing objects on tiles

O

Olezen

Guest
Hello!
I bought GameMaker Studio 2 a couple of days ago, and decided I would continue working on a GMS 1.4 project. This was a newer project, so I had not yet imported some of my standard engine stuff.
One of the things I didn't get around to importing, was a system that would automatically create objects on every tile in the room, for collisions with the player.
So I decided I would attempt to remake that system in GMS 2.0. I immediately found out that the function "tile_layer_find" was missing.
So my question is as follows: Is there any function I can use to "detect" every tile on a certain layer in a room?

EDIT:
I tried importing a project that already had the system in place. It worked fine, and created the objects where they should be created. I checked the room, and found out it worked because the tiles were sprites (only part of the tileset sprite) on an asset layer. I tried creating another layer at the same depth, and placed some tiles on it, and it did not create the objects.
Is there any way to check for tiles at a position in a room now that "tile_layer_find" is obsolete?

- Olezen
 
Last edited by a moderator:

GMWolf

aka fel666
Please don't fill you room with objects to have tile collisions! Please don't!

Just collide directly with the tilemap! Use the tilemap functions to get tilemap data at each pixel and collide with that!
 
O

Olezen

Guest
Maybe this is what you're looking for: tilemap_get_at_pixel?
The whole tiles/layer system has changed from 1.x and you should really read through the manual as there are lots of new functions:
http://help.yoyogames.com/hc/en-us/articles/231539867-GameMaker-Studio-2-New-Functions-List
http://docs2.yoyogames.com/
Yes, I did end up using "tilemap_get_at_pixel" after reading that excact post a couple of minutes ago. Thank you for the response.

Please don't fill you room with objects to have tile collisions! Please don't!

Just collide directly with the tilemap! Use the tilemap functions to get tilemap data at each pixel and collide with that!
What I'm doing, is I'm placing a single, solid object on every tile. Then, every solid object checks for objects to the right of itself, and below itself. If it finds another solid object, it will destroy that object and scale itself to take it's place. That way, I use far fewer objects, which results in better performance. But I'll look into your suggestion, thanks for responding.

EDIT: I'm also using the solid objects for collisions with physics objects, and I don't think that is possible with tilemaps.
 

GMWolf

aka fel666
I'm also using the solid objects for collisions with physics objects, and I don't think that is possible with tilemaps.
Ah ok. With physics objects its fine. (THough, there is a very hard way to do it without...).
 

xot

GMLscripter
GMC Elder
You may also want to see the dungeon demo. It does this sort of thing too for some tiles.
 
Top