inertias
Member
So someone asked a question on reddit about instances following the individual object that creates them.
If you look at the posted solution, it works perfectly but I don't understand why. Here's what they wrote:
Can anyone either explain or link me to the doc's explanation? Thank you!
If you look at the posted solution, it works perfectly but I don't understand why. Here's what they wrote:
When you create the object, give it a variable that stores the id of the instance that created it.
Code:var inst = instance_create(x,y,obj); inst.creator = id;
Haven't been programming for long so I don't understand the "inst.creator" part. What exactly is happening there? What is "creator" in this case? I've only seen the use of a "." to reference a variable from an object. For example, obj_player.x will get the player's x coordinate. So what is inst.creator doing?Now, since the newly created instance of that object has that variable, you can use it to snap to that position.
Code:x = creator.x; y = creator.y;
Can anyone either explain or link me to the doc's explanation? Thank you!