Advanced wandering logic

Ive been working on utilizing raycast in some newer ways to find out if I could work on some Pathfinding. I decided to start a new game that uses a randomly generated map, theres a few enemy tanks that will wander around the map, and Ill explain how they work. Wandering is the first step to pathfinding because the tank needs to know which directions it can go without hitting an object

There are 3 raycasts. One pointing ahead, and two pointing to either side. When the center raycast hits a wall, the tank will recognize if its about to hit something. It will turn either left or right, unless the side raycasts detect a wall, in which case it will not allow. In the case of a dead end, if all 3 casts are active, the tank will turn completely around.

If a tank is traveling down a corridor and detects theres an opening (via side raycasts) it may turn and travel down that corridor instead of continuing straight.

Heres the REAL fun. If a tank ever detects the player, it runs a raycast in the direction of the player, If that raycast hits, it has a line of sight on the player and will attempt to fire at them if it can rotate its gun fast enough, but it will not chase them.

If a tank detects that theres a strong breakable block it will drop a bomb, this bomb goes off after 10 seconds and will hit anyone in its radius, but will also allow the tanks another option. (They arent that smart and may blow themselves up in the process)

https://flowlab.io/game/view/1034204

The thing was acting a little unstable, so i rebuilt it and I also integrated a crap ton of logic gates to ensure it works. Yeeeee

Interesting. Is this a new project you’re working on?

I guess

Very cool! You probably already planned to do this, but the player aiming would work better if you account for the camera position like in https://flowlab.io/game/play/685073

@grazer, yeah, I planned it but couldnt find the time

join the club :slight_smile: