• Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!

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

Member
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.
 
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