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

Legacy GM Collision lag: Can distance_to_object negate lag?

Dr_Nomz

Member
I have a bunch of zombies that usually end up clumping together, and one of the ways I keep them from staying that way is by having them move away from eachother in the "collision with zombie" event, so if two of the same object collide with one another, they'll both start moving a certain direction.

But this can cause A LOT of lag if they're all running these collision events, so what about distance_to_object? Can I just use that in the step event without issue, or will I have the same lag problem?
 

TheouAegis

Member
It should help. It's essentially moving one aspect out of the equation.

Another idea to consider for speed tests might be to snap the destination coordinates to a small grid, then compare all the other zombie positions on the small grid.

Code:
 ///Using 4x4 grid
var x1=x+hspd >> 2,
y1=y+vspd >>2,
x2,y2;

with zombie_parent {
   x2 = x+hspd>>2;
   y2 = y+vspd>>2;
   if x1==x2 && y1==y2 {
       other.hspd = 0;
       other.vspd = 0;
       break;
   }
}
 
Top