Changing child actor z-depth.

Questions, comments and discussion about the Game Editor development.

Changing child actor z-depth.

Postby bamby1983 » Mon Jan 07, 2013 3:45 am

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
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score

Re: Changing child actor z-depth.

Postby skydereign » Mon Jan 07, 2013 4:03 am

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;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Changing child actor z-depth.

Postby bamby1983 » Wed Jan 09, 2013 2:21 am

Thanks, that worked really well! That was a great workaround! :D
bamby1983
 
Posts: 112
Joined: Tue Jul 31, 2012 11:36 pm
Score: 8 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron