Hi? I am only a beginner on using unity 3d. I wonder how to create an enemy AI that moves randomly on a specific place?

the 3d game that i will develop is the same as the game Battle City that often we play on a family computer. just need some help on making enemy tank AI to move randomly. Every answer will be very much appreciated. Thank you. :slight_smile:

One solution would be to use the NavMesh feature in Unity. You can then give your agent a randomly chosen destination with the SetDestination API.

If you want a really stupid AI :

you need some functions such as : GetRandomDirection, MoveForward and some variables such as : MinTimeBeforeChangingDirection, MaxTimeBeforeChangingDirection, Speed

If you want something more nice :

Check NavMesh, NavMeshAgent, and instead of getting a random direction, get a random Transform point within a list of positions that your agent could need to go.

(if your map is an ‘house’, or something complicated)

You can also mix these two solutions :

Get a random position then ask your agent to go there, using the navmesh.
Once he finished, do it again :stuck_out_tongue:

(if your map is a cube)

Happy coding :slight_smile: