Page 1 of 1

Changing child actor z-depth.

PostPosted: Mon Jan 07, 2013 3:45 am
by bamby1983
I understand the child actor inherits the parent's z-depth. Moreover, the child actor always seems to be "on top off" the parent as though it had aslightly higher z-depth. I wanted to check whether it is possible to:
1) change the child's z-depth due to an event
2) permanently set the child's z-depth to be less that the parent's

In case you would like to understand the scenario I'm designing, here it is. A soldier walks into water and a collision event makes the child actor (ripples of water around him) visible. Upon leaving the pool. the child actor disappears. The ripples need to:
1) be underneath the soldier
2) have a smaller z-depth than the border surrounding the water body so they do not spill onto the shore.

The attached file shows what I want to achieve.

GE_ZDepth_Issue.jpg

Re: Changing child actor z-depth.

PostPosted: Mon Jan 07, 2013 4:03 am
by skydereign
bamby1983 wrote:1) change the child's z-depth due to an event

You can't target the a child actor with any built in functionality. You would have to create some other way of referencing the actor, like storing clonenames. You can't do this easily though, and usually a better solution is to change the parenting scheme. In this case you can use creator in the ripple actor to reference the soldier.
bamby1983 wrote:2) permanently set the child's z-depth to be less that the parent's

Not possible. The child is bound to the same zdepth as its parent. So it can never change in terms of the entire game. But, all actors sharing the same parent can have different zdepth values set by ChangeZDepth relative to the each other.

So if you want the actor to follow the soldier, you can do something like this instead.
ripple -> Draw Actor -> Script Editor
Code: Select all
x=creator.x;
y=creator.y;

Re: Changing child actor z-depth.

PostPosted: Wed Jan 09, 2013 2:21 am
by bamby1983
Thanks, that worked really well! That was a great workaround! :D