• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM (SOLVED) object_get_parent Questions

When using object_get_parent(object_index) do you put in an instance id or an object index? (Does the object need to exist inside the room)

Also (The main question) what happens when the object has multiple parents? Here is the kind of family of the objects i'm using:
obj_brickWall < wall < world_object < has_lighting
(I know, i know. It's a mess but it does what i need it to do) My question is what would object_get_parent(obj_brickWall) return? I'm guessing wall but thought i would double check
 

FrostyCat

Redemption Seeker
object_get_parent() only accepts object IDs, just like all other object_get_*() and object_set_*() functions. There is no need to have an instance of the object in the room, all of these functions work on the object resource directly.

object_get_parent() returns the immediate parent, so in your case object_get_parent(obj_brickWall) would give wall.
 
D

dugtrioramen

Guest
When using object_get_parent(object_index) do you put in an instance id or an object index? (Does the object need to exist inside the room)

Also (The main question) what happens when the object has multiple parents? Here is the kind of family of the objects i'm using:
obj_brickWall < wall < world_object < has_lighting
(I know, i know. It's a mess but it does what i need it to do) My question is what would object_get_parent(obj_brickWall) return? I'm guessing wall but thought i would double check
Yeah I had the same question yesterday, and after messing around a little in my own project, I could only get the direct parent with that function alone. In your example it would just be wall like you said.

As for your first question, I think you could put an instance id, but just to be safe,
instance.object_index
 
object_get_parent() only accepts object IDs, just like all other object_get_*() and object_set_*() functions. There is no need to have an instance of the object in the room, all of these functions work on the object resource directly.

object_get_parent() returns the immediate parent, so in your case object_get_parent(obj_brickWall) would give wall.
Do you mean Object Index instead of object ID? And perfect that's what i was hoping. Thanks alot!

Yeah I had the same question yesterday, and after messing around a little in my own project, I could only get the direct parent with that function alone. In your example it would just be wall like you said.

As for your first question, I think you could put an instance id, but just to be safe,
instance.object_index
I have tested it and it's the object index so i just used object_get_parent(obj_brickWall). Not sure if it needs to exist as i did have the objects in the room when i tested but it seems like it doesn't need to exist. Thanks for everyone's help
 
Top