edited September 2015 in Makinom Support
Hi!

Considering 2D roguelike, i added some basic random movement in Makinom schematics... But i have an issue: when two enemies (spawned through ORK) are near there is the possibility to move on the same tile at the same moment, and the game is blocked with this error:
StackOverflowException
UnityEngine.RaycastHit2D.get_rigidbody ()
UnityEngine.RaycastHit2D.get_transform ()
Makinom.RaycastOutput..ctor (RaycastHit2D hit)
Makinom.RaycastHelper.RaycastAll (RaycastType raycastType, Vector3 origin, Vector3 direction, Single distance, LayerMask layerMask)
Makinom.Schematics.Nodes.RaycastNode.Execute (Makinom.Schematics.Schematic schematic)
Makinom.Schematics.Schematic.ExecuteNextNode ()
Makinom.Schematics.Schematic.NodeFinished (Int32 next)
Makinom.Schematics.Nodes.ChangeVariablesNode.Execute (Makinom.Schematics.Schematic schematic)
Makinom.Schematics.Schematic.ExecuteNextNode ()
Repeating endless...

Basically the schematic choose one random direction (NSWE), check if there is an object with Blocking Layer and if the spot is available moves... But when two enemies are near they could see the spot as "free" and the both move on the same tile, at that point the game is stopped and i get the error.

As the enemy can be identical clones (i could have used priority or some other setting if they were always different), is there any way to prevent this happening? As far as i understood all enemy schematics are performed in the same moment, so i have now way to avoid this situation at the moment. :)

Thanks. ^^

EDIT: i updated the error message, i missed first part.
Post edited by Kaemalux on
  • A stack overflow usually means you've got an endless loop happening in your schematic. You can prevent this error by using the Limit Nodes per Tick setting in the schematic's Settings node.
    This is only to prevent the error, but wont stop your schematic from looping all the time. I'd need to see your schematic (e.g. screenshot) to tell you more.

    You could solve this by either performing the enemy movement after each other (like it's done in the roguelike tutorial, which is basically a turn based game), or store the move targets (positions) of your enemies in a list and remove them from there once they moved there to prevent other enemies from using the same spot. Naturally, you'll also need to check the list before moving there :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks!

    Actually, as base setup, i am using your 2D Roguelike as movement manager, and i checked that Wait and Single Execution are ticked, but i still get the error. In my schematic enemies have to wait only while moving (0.1 second), but that wait should still be enough to not be considered in the same moment. Do you think that pause is too little to be recognized or the problem is the schematic itself? ^^
  • If you're using it like that, it's guaranteed that the next machine starts after the previous has finished, i.e. 2 enemies can't move to the same position.

    The problem should be in the schematic having a loop (most likely for the Failed part of the raycast).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I noticed that actually is the 0.1 movement without waiting time... :)

    I would like to speed up everything but it seems i must let enemies moves waiting for them to finish.

    Any tip about having a fixed waiting time instead of a sum? If i have 4 enemies in range the wait for the player is surely bigger than with only 1, any way to prevent this? ^^

    Thanks a lot!
  • A fixed waiting time will lead to the same problem. You could reduce the time used for moving and waiting (e.g. 0.05).

    Like I said - adding the move target positions to a variable list and checking if the position is already taken is a solution for that.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Okey, thanks a lot. ^^
    As a side note, when i try to set movement to less than 0.1 the enemy start behaving weirdly, it keeps moving really fast like a pinball and the position keeps changing over time. I suppose this is still linked to really fast movement time, but in case you wanna check it i just wanted to tell you. :)
Sign In or Register to comment.