Grandparents checking? (or somewhat)

NoFontNL

Member
Parents checking I know of, but when a parent is a child of another object, I can't check the grandparent. For example:

Object: obj_ground | child of: par_ground
Object: par_ground | child of: par_solid
Object: obj_pipe | child of: par_solid
Object: par_solid | child of: **none**

Then, if I do

if (place_meeting(x,y,par_solid)) { show_message('colliding with solid object') }

the message won't popup, if I am in an obj_ground object.

Is there a way around it? Because in my case, I'm checking if I'm in the par_ground, then die. But not when I'm in a pipe. So I don't want the pipe to be a child of par_ground. Therefore I made par_solid, so you can stand on it, but won't die when you're inside it.

So back to the point, is there a way to check for grandparents? Or is there a work-around?
 

Smiechu

Member
You need to make for example double check...
I.e.
if place_meeting(x,y,grand_parent){
if place_meeting(x,y,parent){...

Other use object_is_ancestor finction...
 

XirmiX

Member
What @Smiechu said, but if you're also looking for how to select the parent object of the parent, you would need to set a variable inside the parent object that is set to its parent object type or instance (the grandparent). So for instance, in your parent object:
Code:
grand_parent = obj_grandparent;
Then in your child object, to check collision with grandparent:
Code:
grand_parent = parent.grand_parent;

if place_meeting(x,y,grand_parent){
...
}
 

NoFontNL

Member
What @Smiechu said, but if you're also looking for how to select the parent object of the parent, you would need to set a variable inside the parent object that is set to its parent object type or instance (the grandparent). So for instance, in your parent object:
Code:
grand_parent = obj_grandparent;
Then in your child object, to check collision with grandparent:
Code:
grand_parent = parent.grand_parent;

if place_meeting(x,y,grand_parent){
...
}
How do I check for the children of them, like if I check for a parent, then also the children are involved.
How do I do that?
 
Top