How to use node "Construct object from class"


well, in my game, i have entities “armies” and they “hire troops”, so i think want to make an object of a base class “unit”, add in to an array of objects, and then modify it adding to its map variables new keys and values.
Currently i’m stuck with the step of creating the object from class, i don’t need to spawn actor into the scene and it’s enough for me to just have a record that the unit exists, and i’m stuck with an error that is on screenshot, also i don’t know what an instigator is (in this case), browsing internet there were suggestions that only widgets can be constructed this way, if so, then how other way i can make the desired outcome?

you can only construct Objects, you’re trying to construct a Pawn which requires spawn actor.

i know you said you don’t need to spawn but that’s the way it is.

you could separate the UnitData (Object) from the UnitPawn (Actor) if that’s the way you want to go?

then i have a question how can i create an objects that can hold different variables and then add hem to an array?

construct object is correct, you can add the return value to an array.

but you have to change your input class to an Object Class Reference
you create your object base class the same way you create a pawn, just do new blueprint class and select UObject as the base class

the instigator is who created the object, so it could be the PlayerController for example or its can be left Null

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.