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

GML Step event or collision check for attacks?

A

anthropus

Guest
Hi all. Im still fairly noob but learning more everyday.
In some (melee/projectile) attack tutorials they say to use a collision check event to initiate the code of dealing damage etc, and in others they say to put that code in the step event.

which is better [for what purposes] and why?

I've been following a lot of these tutorials in my practice game so my code is a combination of the 2 (collision check event and step event) and its getting sloppy and buggy. I want to have a standard way of handling the attacks, but Im not sure which to go with: collision event or step event.
I was thinking I would settle for putting all the "attack/hit" code in the step event bc the weapons dont exist until the actual attack actually takes place and it generally seems to work better for me than collision event for some reason, but I dont want to decide until I hear from other more evolved Homos

thanks!
 
J

jb skaggs

Guest
I try not to have huge codes running every step.

I like to use the the collision to initiate a instance_destroy() of the bullet then run code in the destroy event of the bullet- so that the same bullet does not keep steeping damage every step or collision step.
 
J

JFitch

Guest
Advantage of collision event: You can use "other".
Advantage of collision code in step event: You can check for a collision in the middle of a step, as opposed to a separate event for the collision which will be performed either after or before the entire step event. For example, if you want the collision mask to be larger for this specific collision, you can scale it up, check the collision, then scale it back down.
 
Top