• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Collision of multiple objects

D

David Krejcik

Guest
Hello, I am new to GML and currently working on a platformer in which a secondary tool allows you to place your own platform. I got the basic functionality and tool switching done, but as of now I can create the object anywhere in the room including inside enemies and my player and I would like to set it so that it can only be created when it is not in collision with some objects (player, enemies, walls).

Now, my question is if there is a short way to check for collisions of multiple different objects across multiple layers with the platform object in question. I cannot use the 'all' keyword since some objects like signs I want to keep "over-placable".

Since I am checking for collisions of multiple different objects and their individual instances I could write it for each individual object, but since I also plan to have more distinct kind-of-wall-objects and types of enemies, that seems like an ineffective solution.

Thanks.
 

2Dcube

Member
You can create empty objects that act as "parent object", which you can then check collisions with.
In the Object Editor window, there is an option to set the parent.

For example, you could give objEnemy, objWall, objPlayer all the parent object of "objCollidableParent" or something, and use it in collision checks.

Would that help with your problem?
 
D

David Krejcik

Guest
You can create empty objects that act as "parent object", which you can then check collisions with.
In the Object Editor window, there is an option to set the parent.

For example, you could give objEnemy, objWall, objPlayer all the parent object of "objCollidableParent" or something, and use it in collision checks.

Would that help with your problem?
yeah, I think that will work for what I have in mind, thanks
 
Top