[Solved] Can objects be created using a string of it's name?

I’m creating an in-game level editor, allowing level to be made and saved while playing the game. Saving and retrieving the level objects’ details to and from storage works fine. But creating the objects seems a bit cumbersome. Is it possible to create a new object from it’s name that has been stored as a string, rather than by the object type?

So would it possible to store the object type name, and use it in an action recreate it? So something like 'Create object <name stored in variable> at position...'?

Or must an event be made to test the string against each object type, and then in the action 'Create object <object type> at position...' be used?

1 Like

You can use the “Create an object from its name” action.

Here I’ve set a scene variable to an objects name and used the below action to spawn either object A or object B dependant on the variable spawn on key press.

Spawning objects in this fashion does however require they be grouped together.

I just has an ‘well, DUH’ moment with that screen shot. It’s the group thing I hadn’t quite figured out (but seems so obvious now).

Thanks for the quick response.

1 Like

No problem, I only recently discovered this function myself :slight_smile:

So that part works, but how can you reference the newly created object and set the attributes of the newly created object? Like it’s z property or rotation?

Flag that. I should have tried it out before I asked.

Just reference the group name. So in convictedweirdo’s screen shot, something like:

Change the z-order of spawnGroup: set to 2