Hi everyone, i am very new to Unreal Engine. I have been following a video tutorial to get started on an idea for a horror game, i am trying to get two different enemy AI’s to both attack when approaching the character.
I have cast the attack task to one AI and I am struggling to also get the other AI to attack at the same time as i can only have one “Event Receive Execute AI”.
I have been searching for an answer all day to no avail.
Please can someone help me!
Thanks.
hello,
this should work no matter how many AI exist.
every AI has its own copy of the same script.they don’t affect each other.
Hi, thanks for the reply. I should have been clearer.
I have two separate AI blueprints for two different characters, e.g. BP_AI and BP_AI1.
The cast as above is to one of the AI, and I’m trying to figure out how to cast to BP_AI and BP_AI1 from the same behavior tree.
Does this make sense?
Hey @DishonoredBrit! Welcome to the forums!
Is your BP_AI1 and child of BP_AI? Also, a better way to execute this may be to use a blueprint interface. This will give you more flexibility than casting will:
Let me know if this works for you!
yes it makes sense.however you’ll have to create a base enemy class and have the two separate AIs to inherit from the base class. and the “attack player” function should be placed in the base class.
this way you can cast to the base enemy class ,call its functions,it will trigger the function in the specific child class.
or use interfaces as above mentioned.
Thank you both, @baobao4435 and @Quetzalcodename . I really appreciate the help.
As I mentioned, I am very new, so I wasn’t aware of creating a child of the BP. That did work initially, but the animations are causing the child AI to disfigure upon attacking as they have a different mesh, i suspect.
I will look into this, and with interfacing, i wouldn’t even know where to start with calling the right function. I have some work to do! Thanks
Hey @DishonoredBrit,
To help get you started looking into interfaces, check out these great non-Epic overviews on their functionality and the comparison between the two for implementation purposes:
I hope that helps point you in the direction you need!
Hey @DishonoredBrit,
Checking in. Did you still need help with your AI? Was the above the solution you were looking for?