• 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!

Windows Should I avoid using place_meeting() when I can just use the collision event?

L

LilRony

Guest
I can't find any confirmation on this, but I hear that place_meeting() should only be used when checking for instances at a direction, while collision events are better for collision in general. Is this right?
 

RangerX

Member
Each function is having a reason.
If you just want to know if you collide or not --> use place_meeting() because that function will return 1 or 0 (true or false).

If you need to interact with what you collide with, use the "collision" family as they will return the instance ID of what they collide with. Collision functions are also great for "special collisions" where you only want to check a dot, a line, a shape, etc

A collision event if is like place_meeting. If it collides, the code in that event will be read and executed.
 
L

LilRony

Guest
Each function is having a reason.
If you just want to know if you collide or not --> use place_meeting() because that function will return 1 or 0 (true or false).

If you need to interact with what you collide with, use the "collision" family as they will return the instance ID of what they collide with. Collision functions are also great for "special collisions" where you only want to check a dot, a line, a shape, etc

A collision event if is like place_meeting. If it collides, the code in that event will be read and executed.
Okay, thank you for the answer. To build on that, how much should collision be limited? My profiler says that place_meeting() registers at about 20% for just the player, which seems way too high considering the framerate I was getting...
 

Roa

Member
For any instance collisions, I always use place_meeting() vs collision events. Im pretty sure its faster too.
 
H

Heat4Life

Guest
Yeah, I've been wondering too If place_meeting() is just for checking if the given instance has been collided on THAT POSITION... but the Collision Event is for everything...
 

Roa

Member
Yeah, I've been wondering too If place_meeting() is just for checking if the given instance has been collided on THAT POSITION... but the Collision Event is for everything...
place_meeting checks everypixel of the collision mask to the opposite instance spoken of. position_meeting checks a single pixel. place_meeting is fast if you use collision boundings vs per-pixel checking. The added advantages is that you control exactly when to check for said instance instead of checks being run on every instance everyframe just for the collision_event handler to even exist.
 
H

Heat4Life

Guest
Yeah, I'm just gonna experiment with this so I can Understand It better...
 

TheouAegis

Member
The biggest difference is that the Collision events will fire for every single object in a collision. Place meeting will only fire for one single instance. So if there are 20 collisions with the player, using a collision event all 20 of those collisions will be registered, but otherwise Place meeting would only register one of those collisions.
 
Top