Search Unity

Reordering Update() order on the fly

Discussion in 'General Discussion' started by kevdotbadger, Feb 1, 2015.

  1. kevdotbadger


    Sep 13, 2011
    Hello, I have a simple grid based game where you move circles around (they move 32pixel at a time), however they all move at the same time. So pressing up would move all the circles up.

    Take a look at 2015-02-01 21.22.46.png?dl=0 for a preview.

    I've created a method so that when a circles is moved, it loops through the locations of all the circles and works out if the next grid position can be walked on. This is done to ensure 2 circles don't ever share the same position.

    So if I pressed up, it checks to see if the next cube is walkable. However, the problem is that it seems that the order Update() is run causes problems. When pressing up, the Update() should be from north to south, when pressing down the Update() order should be south to north. This ensures that the first circle moves before the second circle checks it's next position.

    Any one have any ideas how I can do this? If i could update the Update() order then I could use a generic .Sort() call to sort the circle.
  2. Redtail87


    Jul 17, 2013
    Call the methods explicitly from a manager class. Use a list of the objects in the order you need them then just loop over and call them.
  3. Kiwasi


    Dec 5, 2013
    A double buffer solution might also help