Download

Getting variables from an NPC

Hi. I am trying to make a blueprint that allows an NPC to read certain variables from another NPC once it is within touching distance. I have the variables set up and available and I have the NPC moving to the other NPC, but I do not know how I would go about getting the values upon contact. How could I do this?

Any help is appreciated. Thank you!

Hi Lancelot185,
I would add a sphere collision component to one of the two NPCs. Then when that component gets a collision, you can check if the actor it hit is the other NPC, and if yes get the variables.

Thanks a lot, I’ll give that a try!

Yes, since your NPC’s are “touching” each other, you should work with collision shapes and overlap events.
The “Other Actor” parameter that comes with the overlap Event can then be used to cast to your NPC class
and get the variables you need.

I’m working on something similar and this part has me stumped, I’m using a multispheretrace and want to cast to ojects hit, determine if they have an interactivity function and then and then Fire only the one with the highest noted priority if I’ve traced multiple hits, how do i go about viewing those potential variables?