Page 1 of 1

Parenting the Hud

PostPosted: Wed Oct 06, 2010 6:54 pm
by Leeesaw
I want the hud follow the player (or to follow the view which is following the player).

but I want to player to be able to pass behind objects/walls (game objects)... yet have the hud still stay on top.
Parenting doesnt allow this.

Please help. :D

Re: Parenting the Hud

PostPosted: Wed Oct 06, 2010 7:01 pm
by skydereign
Instead of parenting the player, have the hud parent a new actor and in its draw event, set its x and y equal to the player actors. In its create set the zdepth to some high number and change its visibility state.

parentActor -> Draw Actor -> Script Editor
Code: Select all
x=player.x;
y=player.y;


parentActor -> Create Actor -> Script Editor
Code: Select all
VisibilityState("Event Actor", DONT_DRAW_ONLY);
ChangeZDepth("Event Actor", 50);

Re: Parenting the Hud

PostPosted: Wed Oct 06, 2010 7:35 pm
by Leeesaw
Thanks for the quick reply and the feedback. The problem now, is that the hud jitters when my player is colliding. :S

Re: Parenting the Hud

PostPosted: Wed Oct 06, 2010 7:59 pm
by skydereign
Yeah, it works depending on your collisions, this is probably more stable a method. Instead of a new actor for parent, have the hud parent the view, and set it with this.
view -> Draw Actor -> Script Editor
Code: Select all
x=max(player.x-width/2-2,min(x,player.x-width/2+2));
y=max(player.y-width/2-2,min(y,player.y-width/2+2));

Re: Parenting the Hud

PostPosted: Thu Oct 07, 2010 2:12 am
by Leeesaw
BRILLIANT! Thanks so much! It works perfectly! :D