Has Received Event not working as expected

VagabondOfHell

New member
Hi Justin

I am looking to use Has Received Event for when the NPC hears a sound from my sound manager. Unfortunately I can't seem to get the Has Received Event to return true.

I've structured a sample like so:

upload_2019-3-12_21-0-12-png.388183


And added some debug statements inside the Has Received Event. The Registered is called, but RECEIVED is never called.

upload_2019-3-12_21-1-47-png.388186


Registering to the event in another script works fine however. I get the received message and the desired vector

upload_2019-3-12_21-2-41-png.388189


Do you have any suggestions for determining why the ReceivedEvent of the Conditional Task isn't working? I didn't post this in the bugs section because I'm assuming I'm just doing something wrong. (Also I posted on the Unity Forum before I realized I should post it here).

Thanks for your time

Adam
 

Justin

Administrator
Staff member
When is that event sent? Has Received Event is looking for the generic <object> version of the event, so you'll need to make sure you use ExecuteEvent with the generic object:

Code:
behaviorTree.ExecuteEvemt<object>("SoundHeard", (object)myVector3);
 

VagabondOfHell

New member
That was the issue.

In the documentation regarding this, the line says "If the Has Received Event task is receiving event then the template type must be a valid of object. ", and I interpreted it as "Valid Object" or not null, instead of "a value of Object".

I knew it was something I was doing wrong, thank you very much!
 
Top