Enemy Ai Help

Started by
3 comments, last by Thaumaturge 2 years, 4 months ago

Im not sure if im in the right place but I need some help with enemy AI in my fps game. I want to put the gun script into the Attack code so it can use it to fire at the player but im a beginner and have no idea how.

Gun script

Ai

Advertisement

Moved to the Artificial Intelligence forum. Good luck with your question!

-- Tom Sloper -- sloperama.com

Never used Unity, but something along these lines perhaps??

Simplest is to add a ‘target’ variable to the gun, and a method ‘setTarget’ which changes that target variable. The gunn simply shoot at the target that you set. From the AI code, you then call that method with the target to aim for.

Basically, the ai code and the gun talk to each other internally, exchanging information. (Or in this case, the ai giving “orders” to the gun what to do.)

I'm likewise not all that familiar with Unity (any more), but I would imagine that one approach might be to give your “enemy”-class an instance of the “gun”-class. It would then, in the “attacking” method, call the “shoot” method of the “gun”-instance, perhaps passing in a location from which to shoot and a direction in which to shoot, or some such thing.

MWAHAHAHAHAHAHA!!!

My Twitter Account: @EbornIan

This topic is closed to new replies.

Advertisement