In need of help creating a Tank AI System

  1. What do I want to achieve? I am trying to achieve a working tank system for my game. To explain this, I am trying to create a custom module that has a working AI system. For example, it can drive up and down to a specific place like PathFinding.

  2. What is the issue? I am not sure how to develop a system for that.

  3. What solutions have you tried so far? I’ve learned raycasting before but I am not sure how to use it for this. If you have any ideas please comment down in this post.

This is complex and you should break it down into parts. Roblox has a built in set of tools for pathfinding, which you will need, and should use the built in ones because they’re pretty easy. Because the thing you want to have move, the “agent”, a tank in this case, is not just a single point, you will also need something called steering, which takes the result from the pathfinding system and tells the tank how to drive along the path. This part is not as hard but I don’t know of a built in system to do it. Here is a video I found that shows one possible method: Godot Recipe: AI - Context-based Steering - YouTube

This other video is a good overview of these systems in general:

Lastly your tanks need some method of decision making, if you want them to be able to act as NPC enemies / friendlies. This one is a lot more abstract and I’m not sure how I would approach it. Probably you want your AI to try and capture certain areas, while trying to stay out of view of places they know enemies are. The biggest thing about decision making AI is that a little bit goes a long way, not a lot of complexity is needed to convince the player the AI is smart.

All of these systems are separated in this way because they can mostly be developed separately. You can create “dummy” sytems for testing how they would work together. For example, if you want to start on the decision making part first, you just need to convince that system that it’s actually controlling a tank, when in reality it could just be a brick you are manually driving around in response to it’s commands.

If your maps are not dynamic (the obstacles dont move or change shape) then one of the cheapest tricks you could do is flow-field steering. Manually place arrows on your map that the tanks try to follow. Give them some desire to avoid crowding so they spread out when they hit forks in the path. Then, for decision making, when they sense little resistance / no enemies, have them follow the flow field quickly. If there is moderate resistance, have them slow down or stop, and when there’s too much resistance, have them reverse along the same path to make them retreat. This has the potential to look very “smart” to players, even though the tanks are only ever deciding whether to go forward or backward along the field.

1 Like