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

GameMaker [SOLVED] Is there a difference between collision event and collision code in step event?

MartinK12

Member
Like in the title is there a difference between using collision event or placing my own collision code in the step event?

I assume that when I put my own collision code in step event it's going to be run every step, but collision event is also running every step, right? So is there a difference between those two? Maybe performance wise?

Thank You :)
 

samspade

Member
As far as I know, the collision event is directly equivalent to putting the following in a step event:

Code:
if (place_meeting(x, y, object)) {
     ///do stuff
}
If there is a difference it would be minimal. The real difference is control. While I'm a fan of most events, the collision event is one I never use as it is pretty rare that the pure vanilla place_meeting works for what I am doing.
 

TheouAegis

Member
Biggest difference is the colliding instance is registered in an event.

Code:
if (!place_meeting(xprevious, yprevious, other.id)) {
    ///do stuff
}
That code will work in a collision event. It will not work within the block proceeding samspade's code since other points back to the calling instance at that point.

The step event equivalent is
Code:
with instance_place(x,y,object)
 with other {
    //code
}
 
Top