Automatically create actor from within a blueprint Object, and set appropriate variables at spawn

This is a massive long shot but I’m giving it a go.

I have a quest system and it relies upon objective being an actor in the world. In order for the actor to know which Stage of the Quest and which Objective within that stage the Objective Actor contains with integers which are the indexes of the relevant arrays.

My ideal situation would allow me to Spawn an Objective Actor from the Quest Object in the Objective array element (like you can create a new Gamemode in the World Settings or create new blueprints within the Gamemode blueprint) and automatically set the Stage and Objective indexes when it’s spawned.
I’m pretty sure this can’t be done in blueprints but wondered if there is a way in C++ to create a button like that within an object.

Can you create utilities like that and tie them to an array element?

Hi @Elrekay
got pretty confused here, but i am pretty sure that you can do it with blueprint.
Can you define a little clearer what you need ?

So I found half of it.
When I define a variable as a class instead of a actor reference then I can create new classes and insert it in the element.
the image attached should help.

To be honest I think I got close enough to what I wanted, it’ll just take a little more effort in the long term.

What I would do:

Not use indexes

I think the indirection of indexes are not helping any. This is actually orthogonal to the “how to wire this up” question, though.

When spawning an objective, make every objective derive from a generic objective marker class. The generic objective marker has two properties; “Stage” and “Objective” of type Stage-object, and Objective-object. These are marked “expose on Spawn” in the blueprint editor.

The Quest has an array of Stages, each Stage has an array of Objectives.

When spawning an objective marker using the Spawn Actor From Class function in Blueprint, once you know that the class will be a subclass of GenericObjectiveActor, the node will add the values that are “expose on Spawn,” so you can plug in your Stage and Objective values right into the spawn call.

1 Like