GM:S 1.4 Collision lag: Can distance_to_object negate lag?

Discussion in 'Programming' started by Dr_Nomz, Aug 14, 2019.

  1. Dr_Nomz

    Dr_Nomz Member

    Oct 31, 2016
    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?
  2. TheouAegis

    TheouAegis Member

    Jul 3, 2016
    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.

     ///Using 4x4 grid
    var x1=x+hspd >> 2,
    y1=y+vspd >>2,
    with zombie_parent {
       x2 = x+hspd>>2;
       y2 = y+vspd>>2;
       if x1==x2 && y1==y2 {
           other.hspd = 0;
           other.vspd = 0;
    Dr_Nomz and The Reverend like this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice