Hello again. This time I spend more than a day trying to figure this one out myself. I know I should probably be able to fix this myself by now. But I can't seem to remember how if so.
In any case, I have about 20 enemies in my frame that all share the same movement system. Which is basicly
If direction (south) then every "movementspeed1" set ypos of enemy to ypos of enemy +movementspeed2
Nothing too complex. They use 4 directions in total.
When they reach any edge of the frame they will change direction and also get re-positioned by 3 pixels in the opposite direction.
When they overlap a neutral object (something meant to stop them climbing trees and walking through walls etc), I will check where the neutral object is, and where the enemy is with coordinates. To give an example, if enemy xpos
<= to xpos of Neutral. Set xpos of enemy to expos of enemy-2 and change direction to west.
It almost looks good to me. I want to believe that overlaping objects make the instance unique, and it will only use the objects overlaping to compare with.. This work good, well, with only 30 enemies atleast...
Untill an enemy somehow manages to get stuck between 2 neutral objects. when this happens. All enemies will start to get pushed into a corner. Well, they will actually be re-positioned with the current code used, because they think they are still overlaping a neutral object and has to be moved, just because 1 guy got stuck...
I have an example file where I have put an enemy inside the mountain to the northwest. To show the effect of what happens when 1 get stuck. If you want to wait for the "natural" bug you can move it outside again and just wait, there's usually one getting stuck southeast between 2 boulders.
In any case, This code might be usable, IF ONLY one wouldn't get stuck - which I don't even know how it can happen.
If someone would try to help me solve this, I'd appreciate it!
Edit:somehow I managed to paste away this part:
The obstacle collision is in the group Enemies-Obstacles-Original
The enemy movement is under Enemie group - Enemy name- "name" Movement
WASD to move around
Please login to see this link.