[Solved] Using a function to spawn an object from the objects panel?


#1

Hello.
I was wondering if it was possible to spawn an object from my objects panel using a function.
When I try to make an event to spawn an object, it only shows me my function parameters instead of my objects.
The code I’m using to make this is REALLY complicated, but I decided to simplify it with a function.
The code does not need to be shown here. All I need to know is if you can use a “Create Object” action in a function to spawn an object from your objects panel, and if not, if there are any workarounds.

Thanks in advance.


#2

Yes, it’s possible.

When you’re creating the function, you have to set up parameters that correspond with all of the actual objects you want to use. Then when the function is added to a scene or external event sheet, you can select them in the parameter fields.

You’ll never see your actual objects in function events since functions are independent from the rest of the game (if I’m not mistaken) - and this is why you have to use the parameters in conjunction with actual objects.

And for every scene that the function is applied to, all objects included in the function have to exist in your object panel and be defined in the parameters. This is unfortunately the case even if some objects are not needed in all of the scenes, otherwise it won’t work at all.


#3

Thanks, got it working :slight_smile: