Refer to newly created objects inside a function?

If you are creating a new object inside a function, how do you refer to that newly created object while still in the function.

For example (Object to spawn is PARAM1)

Create object (ObjectToSpawn) at postion 0,0
Change the Z Position of (ObjectToSpawn): set to 100

On line 2 it says “This object Exists, but can’t be used here”.

So how do i change the position of the newly created object in the function?

I am not good with extensions
BUT object spawner extension have for sure what you are looking for just open it and examine it

Since it have condition
Object just spawned

I believe you can link something to it.
When the object is created…for that frame…is picked…so you can bind a variable to it.
then use that variable in the expression…
i cant test it…just throwing inputs

Can you post a screenshot of the function. When you create an object, the object gets picked. All other events and subevents use that object until a new event

This is for a function set as an action.
It uses these settings.

And these events

The Second line of command Change the Z Position of (ObjectToSpawn): set to 100 should be set separate as an action without any condition. Try it out and let me know if it works.

If you move the action to set the Z-order to a seperate event then it won’t work. It needs to either be on the same event or a subevent.

If the action is moved it wouldn’t use the new pick list it would use the old list. The list created from the call to the function. It would change the existing or scene picked objects.

You can repick the object using a variable or other condition.

If this is being used in a behavior or a custom object then there could be an issue depending on where it’s placed. Unless it’s Javascript, I don’t see why it would be causing an error.

3 Likes

I dont get it I always use this method to change the size of an object. For example one time I created a bullet but it was small so I simply changed the size of bullet on a separate event as an action.

Due to that, all the further created bullets were of the size I wanted them to be.

If what you’re saying is true then can the user not create a checker?

It will check the z-order every x seconds and if the z-order is not equal to the one the user wants then it sets it to the one user wants?

If the event is not in the event or a child of the event that creates the object then the object will be mixed with the other objects. You could use a condition to repick it. Almost all conditions pick the related object. The exceptions are compare 2 numbers or strings and a few others that don’t reference the object.

1 Like

“here” doesn’t mean inside a function. It means that your object parameter is not declared as a 3D object so you can’t change its Z position.