Hey guys ! really dont want to post here but hey I dont know any further.
Im having this DungeonManager who iterates over all enemies to do thier stuff.
If an enemy can shoot at the player he does so and confirms his action.
If he cant shoot he proceeds to move to a position from where he can shoot at the player.
Both action work perfectly fine as long as there is only one enemy.
If there are two everything still works as long as at least one shoots at the player.
If two enemy want to perform the move action unity crashes and here comes the really weird thing.
The crash then occurs in the following coroutine:
Now the movement is tile based and the “int path” parameter contains the tile numbers from start to destination.
for each step i get the tiles position, rotate the character, and proceed to move him in a while loop to its destination.
after each step I Log it to the console.
Now only if both enemies need to move the first enemy crashes in the while loop before reaching the last step in its path.
(Eg. the path is 2 tiles, I get the first step logged, the character moves to the last tile and crashes before the last log)
That feels like an infinite while loop but
1. its works if the 2nd enemy doesnt needs to move.
2. even if i choose to run the while loop for a set amount of times (like with an int i < X, i++) it still crashes.
Now what is even weirder if the DungeonManagers ConfirmActionFinished method
(gets called when an enemy finished his action) calls his own action (index) over and over again,
No crash occurs even if the secound enemy needs to move aswell.
Its like if the next action should be called the loop crashes and doesnt even reaches the point of calling another action, but if its own action will be called the loop doesnt crashes, terminates fine and moves on.
Dunno how to explain this, its just really weird, the coroutine crashes if after the coroutine another enemy would move and it doesnt crashes if not. as if the coroutine would know whats going to happen afterwards. well thanks for everyone reading/helping !