For my enemies (on a 16x16 grid), they each have 4 detectors on each side of them. I can get them to move 16 pixels in a random direction but I can't get them to avoid hitting an obstacle, they end walking on top of obstacle blocks. Although it works well with 1 enemy.
I don't know what to do. :/
If they are all the same object, and just one is colliding, then it's most likely that you'll need to do this:
You will need to spread a value in your object to give them all a unique id.
Then you will need to do a fastloop through each one (do this by comparing loopindex with id value).
Then you can tell the code to run on each enemy.
* Always
- TopDetector: Spread value 0 in alterable value A
- Enemy: Spread value 0 in alterable value A
* Always
- Start loop "foo" NObjects("enemy") times
* On loop "foo"
* TopDetector: Value A == LoopIndex("foo")
* Enemy: Value A == LoopIndex("foo")
- TopDetector: Set position to (0,0) from Enemy
* On loop "foo"
* TopDetector: Value A == LoopIndex("foo")
* Enemy: Value A == LoopIndex("foo")
* Direction of Enemy is (Up)
* (Negate) TopDetector is overlapping backdrop
- [move enemy]