I wanted to make a system where two AIs can pass info to each other to plan an attack for the player I am currently using the State tree system Does anyone knows how to implement the system. i tried the event dispatcher but it is asking for a reference of the task i don’t how to do it. can anyone help me with this
Not sure exactly how to set it up, but there’s a state tree related function node called Send State Tree Event. The pawns or ai controllers trading events would need references to each other so you can grab the state tree component and send an event to it. Then in the state trees, you’d need to add On Event transition rules/triggers using the tag sent by event.
The entire answer would be difficult to write here, but I’d recommend taking a look at the general setup for enemy AI below and use 'Decorators’ as gate keepers for certain paths of behavior. Essentially, you give ‘Enemy 1’ access to a BPI message (or whatever your method), which changes a variable (Boolean usually) for which ‘Enemy 2’ is listening (and/or vice versa).
Smart Enemy AI | (Part 1: Behavior Trees) | Tutorial in Unreal Engine 5 (UE5)
To expand on my previous reply, you could have your ai controller do a large multi-sphere trace for objects around it looking for pawns, and if it hits anything, loop thru the array and see if they have a state tree component. Something like this maybe:
The ai state trees would of course need to be edited to use the event to trigger a transition. I don’t have much xp with state trees tho, so you’ll probably want to check docs for how to handle a payload and such.
i finally fixed it i used the gameplay message system from the ue5 lyra project it worked without the need for references and all. It is by my understanding a lite version of event dispatchers and interfaces without the need for a reference wildcard or anything. by using that we send and receive data between blueprints and in my case between evaluators of two different state trees
Glad you found a solution; cheers.
