Collision Detection in GM 1.4xx

Hello, I am a pixel artist trying to set up a premade room creation and testing workflow for my small team. I really like Tiled so far. I have made a room in Tiled and imported it into Game Maker. It’s mostly working fine and my character can move around the room but is not colliding with walls.

I have a question regarding collisions, Tiled, and Game Maker.

I have a separate “collision” tile that I’ve placed over the wall tiles in Tiled, and set that tile’s bounding area as well. This is not enough for Game Maker. Game Maker laughed at me and nice try though.

So I’ve been scouring forums, reddit, youtube, and google to figure out the easiest way to have Game Maker recognize the Tiled collision settings.

Is this possible? Is there a simple solution? Is there a solution at all? Or is all collision detection done in game maker exclusively?

Currently the focus of the GameMaker export has been on matching the level visually and allowing objects to be instantiated. Actually I haven’t used GameMaker beyond a few short sessions to make sure this part of the export works as expected.

So the question is, how is collision generally done in GameMaker and what should Tiled export to enable a comfortable integration? Eventually I could have a look myself, but if you already have some experience with this any insights would be very appreciated.

For collisions in Game Maker Studio 1.4, take a look at Shaun Spalding’s tutorials on youtube. They are very very useful. Here’s one about collisions specifically :

For collisions in GameMaker, I use a small custom square object that I call “obj_wall”. I instantiate it and stretch it over my tiles to define collisions. Right now I can instantiate this object in Tiled but I can’t change the xscale and yscale. If I change it’s size it’s back to 1:1 in GameMaker.

What would help me is for the height and width defined in Tiled for objects (square objects in that case) be accessible in GameMaker. I tried defining Custom Properties but I don’t know yet how to access them in GameMaker and being able to access width and height directly would be more straight-forward.

Custom properties are not exported to the file at the moment, apart from some properties that are mapped to elements supported by that format (like physics properties and things like “speed”, “persistent”, etc.). Do you have an example of how a custom property should be written out in the room file so that it could be accessed in GameMaker?

If you use a tile object, Tiled will automatically calculate scaleX and scaleY for you. This only works for tile objects, because they have a well-defined “default size” (the size of the tile image), whereas instances of arbitrary types have an unknown base size. Another reason to use a tile object is that you don’t have to manually fill in “obj_wall” for the type of the object, since you can set it on the tile (since Tiled 1.0.2).

Thanks for the clarifications! I’ll try the tile objects. Right now I can do very well with the scaleX and scaleY alone but I opened a ticket before about having origin points of the objects. These would be a useful custom properties.

Every instance has it’s own creation code that is executed once at the room start.
Lets say you have two custom integer property fields and two custom string properties:

  • hp: 100
  • strength: 10
  • question: “Why?”
  • answer: “Why not!”

Thats how it could be saved in the file. (I actually defined this four values in the creation code inside GM to copy it)

    <instance objName="obj_dog1_w" x="1179" y="1049" name="inst_9" locked="0" code="hp=100;&#xA;strength=10;&#xA;question=&quot;Why?&quot;;&#xA;answer=&quot;Why not!&quot;;&#xA;" scaleX="1" scaleY="1" colour="4294967295" rotation="0"/>

Thre reson it looks so messy with all the “&.quot;s” is propably that I wrote the following in the creation code:

    answer="Why not!";

As this whole code is stored inside the <… code="[creation_code]" …>. So the ‘"’ of the creation code are not closing the ‘"’ of the xml code.

Now that I think about it defining single properties is nice but sometimes you write some actual code inside the creation code with if-statements, loops and function-calls so maybe a single “creation code” text-property would do the whole job.

Just an update on this, it is now possible to set the creation code when using the latest development snapshot: