Search Unity

Reordering Update() order on the fly

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

  1. kevdotbadger

    kevdotbadger

    Joined:
    Sep 13, 2011
    Posts:
    82
    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 https://www.dropbox.com/s/014fg62j7q0pxv6/Screenshot 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

    Redtail87

    Joined:
    Jul 17, 2013
    Posts:
    125
    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

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    A double buffer solution might also help