Hi , i hope someone can help me, im in the middle of creating a RTS game, and i have the NPC spawning and im in the middle of selecting job for them NPC, if i click on a NPC Using (Get Hit Result Under Cursor By Channel) and select a job that i want the NPC to do that works fine, the issues im having is that i need to be able to ref each one of them NPC (character blueprint) with spawn and is not placed in world) so i can change there job thought a widget without clicking on NPC, there must be a way to do this, but im not sure how to reference the NPC Individual, I hope this make sense and i hope to hear soon
One of the ways that I have in mind is to use get actor of all classes node with respective to specific character class upon clicking the button. That way, every single character with the specified class will have the availability as the reference. From here on, you have the control of them.
But, an alternative way might be needed if you are dealing with >50 instance classes.
I will add to the answer from @56legion to use Interface calls. Only the actors that have the implementation of this interface method will receive the call and will change the variable you need.
There are 10 NPC running about and we keep spawning more:
- how do we know which one’s job need changing?
- is every NPC represented by its own widget in the UI?
i need to be able to ref each one of them NPC
Either reference them as you spawn them or, better, use Event Dispatchers
; so you never need to reference anything in the first place. Nothing gets hard-coded, there’d be no need to clutter context with another interface, all is event driven, and nothing breaks when NPCs expire.
Atm, there simply is not enough details here to suggest something tangible, though.
i have tried using get all actors of class , i cant seem to get it working but i will try again , thank you for your input,
i have done this, i think i am starting to get somewhere with it, thank you for your help
so every npc starts of without a job, once a job become available i have implmented a widget that you can adjust to how many npc you would like to attach to that job,
yes npc create it own widget so show name age but that genrate when the npc is spawned , i just cant chnage the job variable because im having trouble getting all and changing npc as random, i hope that helps ,
would a class ref array work then random the array , ??? hmmmmm i wonder , thank you for your help