Objects creating other objects and giving them their variables

I know i already made a question a day ago but this is another one i have.

Is it possible to make objects create other objects? If so, is it possible to give the created object/s the creator’s variables?

This is a more specific question but related: how do i make sure the object receives the correct variables from the correct creator(as in, two characters/objects cast fireball at the same time coincidentally and the fireballs have their corresponding creator’s variables. basically, make sure that the fireballs dont have the wrong variables or both creator/caster’s variables

(And if it can be answered at the same time, is it possible to do the contrary when the fireballs collides to calculate the damage/effect?)

How are you creating the objects? Are you using create object or the spawn behavior?

It’s possible, we just need more details otherwise we’re just guessing. A screenshot of your specific events will always get you a quicker and more accurate response.

1 Like

I have not screenshots as i am asking to make sure its possible since i dont wanna end up wasting my time testing if its not possible, soni appreciate you telling me its possible (sorry if i had to specify)

However, what is the difference between the two methods of spawning?

When you do it with create an object the object becomes picked. So, you can make any changes that you want like copying variables. For an exact copy, it would be easier if the variables were all part of a structure variable, then you could just copy the one variable.

If the objects are created with a behavior or spawner then the objects aren’t always automatically “picked”. So, you would have to change the values separately on a different event after “picking”: the object.

Neither way is wrong or better than the other. They would just have to be handled differently.

The basic method would also depend on whether they were different objects or just different instances of the same object. For separate objects, you could copy variables directly from one object to the other. For instance, you might need to use a temporary variable(s) to hold the values because you might need to pick the one object, copy the variables to a scene variable, pick the other object and then copy the variables from the temp variable(s).

It’s honestly a fairly simple process. Just a few lines especially if the variable is a structure and you use the Json events to help with the swap.

1 Like

I see.

While i understand what you mean, i wanna make sure what method i should go for.

Im trying to make it so that when an object (a fighter or your character) attacks, they create the attack animation/effect that takes the corresponding variables (attack or intelligence, any other modifiers, etc), and if the enemy collides (the object will take a variable that determines what team it belongs to), they will take damage or have an additional effect(using the health and damage extension)

Which method do you think would be preferred for this?

In that case, the *create object" would be used. The spawn is for a more consistent and repetitive creation like to spawn enemies. There’s also a create an object by it’s name which lets you create an object by it’s name from a group. That would be useful for firing different types of projectiles while using the same events.

You could create the object, the object would become picked so any other actions would apply to it. You could then change it’s default variables or add new ones. To tag it for ownership both objects could have a variable like id or player and you could copy the value from the player object to the newly created object. IDK if you’re familiar with the linking mechanism. It’s under other conditions and actions. You could also track ownership of the projectile by linking it to the player. It creates a similar reference like a variable but it doesn’t require setting up like a variable ID.

On my phone. When I’m at my PC I can more easily add examples if needed. I know some people are better with examples. You can also look at how the example or templates do it.

1 Like

Here’s an example using an ID number. Each button has an id # 1,2,3. It doesn’t using linking. I might convert it to linking. IDK if you learned about linking.

try me:


1 Like

Omg this is very good! Thank you so much!

You confused me a bit on the ownership part tho. So in order for the object to get the correct object’s variables, all i have to do is specify the id of the creator object is what you meant?

Sorry if i am asking alot/continue asking or im being rdundant-

Ownership might have been a poorly chosen word. But yes, if you use an id variable then you can compare the ID. Or as I said you can use linking that wouldn’t require setting up an ID. IDK if you know what linking is.


When you’re copying the variables between objects, you need to either specify let’s say the source of the projectile object as player or if it’s part of an instance or group then you would need some other condition like a mouse click or a collision or some other condition.

Here’s an example that uses 4 instances of enemy and links the projectile to the object that’s picked at the time using the cursor is on condition. It’s the same concept, instead of picking the object with the id variable, it’s picked with the link take into account condition which is found under other actions. Linking is easier bc it doesn’t take the same setup.

Try it:

source: It’s the same project, so there are leftover objects in the project.

1 Like

Ok now i think i get it!

However, does this imply that an ai/non controlled character can use this, nor can there be multiple instances of this happening at the same time? (Its an active time rpg see)

IF this can only work for one object at a time (as in, one attacker and the defende/defenders), then ill make the game a tactical rpg, as that was my original plan!

I’m not sure of your need or a clear way to do it. But as far as linking, you can link any number of objects to other objects. You just can’t link instances of the same object together. Think of it like a family tree.

It’s all just a way to pick objects. Conditions work like filters. You just need to pick or repick the right ones. This isn’t my genre or expertise but I’ll help if I can.

1 Like

I dont mean this negatively, but this changes my plans alot actually!

Ill go with a tactical rpg then, so i can just focus on mastering linking and make things easier for myself. You really helped me alot thanks!

1 Like

For me, instances and object picking were difficult concepts to understand. I still have have my moments. This a hobby for me. I enjoy the challenge of making things work. They are like little puzzles. It’s not just making things work but doing it efficiently and in the fewest lines. I wish you luck.

1 Like

Thanks for the help and sorry for asking alot😅!

1 Like

Ask away. That’s why we’re here.

1 Like