I am spawning NPC from a list (that work)
I am storing in an array parameter of the spawned NPC (like world position) (that work as well)
I do not know how to retrieve variable that are located inside the NPC that I am spawning
Theses value are expose on spawn
How can I retrieve that
It is working fine! Thank!
Although it says that I dont have to cast as my return value is already from the parent class,
make any sense ?
it does make sense in a way if all your classes inherit from the base class, but since you are using an array it shouldnt have the note. the array variable thats plugged into your spawn, whats its type set to? if its type is the base class then it would eliminate the need for the cast since only child classes of the base could be set.
in any event notes shouldnt cause any problems, its there more to say hey you dont really need this node. though i am curious as to why its there.
to get a variables value from another actor you need to have a specific reference to the actor. so if you want to get a variable from your npc you will need to have a reference to it and that reference needs to be specific down to the class the npc is. this is likely to be an issue is your case due to spawning actors based on a list of different classes. since you dont have a specific reference you would need to identify the npc class via casting but that again could lead to issues.
without knowing about the situation its hard to say for sure what to do, but if all the classes inherited from the same base class and you needed a common variable say hp for instance then it could be done simply. ill try to explain, lets say you have classes A B and C, and they all inherit from class 1. lets also say that you want to be getting the baseHP of the each one when they spawn. in this situation you could put the baseHP variable in the parent class 1, this would make it so each child would also have that variable due to inheriting it from the parent. this would allow you then to take any of the children and cast them to the parent class and it would succeed which would in turn give you access to their base hp value.
so basically you need a way where the variable is common to all, or you will have to have a separate script for each class. you can cast any class to its parent and access the functionality the parent contains, so character has all the functionality of pawn, pawn has the functionality of actor but not of character since its lower in the hierarchy.
Yes the variable type is my base class, with an array value of children actors of that base class
yup explains why the note is there. i assumed that the type was set to actor since many people dont realize it can be changed. since the type is of the base class go ahead and not use the cast its not needed.