AI help (beginner)

so I have these two AI scripts that both work one for patrolling that moves from added points after a wait time and the other for a enemy argo system where if a player gets close enough the enemy chases the player. I’m just wonder how I would go about added them to the same gameobject or if I have to rewrite them in the same script or anything like that any help is greatly appreciated.

I’m on unity version 2021.3.4f1

8302731–1088997–patrolingV3.cs (940 Bytes)
8302731–1089000–EnemyArgo.cs (1.09 KB)

You aren’t getting responses because no one is going to download a file.

Copy and paste them with code tags.

You could do either one of these. If you have two different behaviors then you need to create some logic about when to use one and when to use the other. For example, you could have the patrolling behavior as one script and the other script can check if the player is close and then disable the patrolling script in that case.

You might be interested in reading about “finite state machines”. It’s a computing concept with multiple uses in game dev and other software dev. In terms of game AI, each of the “states” in the state machine might represent different behaviors, such as patrol and attack. Then you just need to define the logic of how and when to go from one state to another. If your use-case is simple enough, it might simply be a few if statements.