Parenting the Hud

Game Editor comments and discussion.

Parenting the Hud

Postby Leeesaw » Wed Oct 06, 2010 6:54 pm

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
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Parenting the Hud

Postby skydereign » Wed Oct 06, 2010 7:01 pm

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

Re: Parenting the Hud

Postby Leeesaw » Wed Oct 06, 2010 7:35 pm

Thanks for the quick reply and the feedback. The problem now, is that the hud jitters when my player is colliding. :S
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score

Re: Parenting the Hud

Postby skydereign » Wed Oct 06, 2010 7:59 pm

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

Re: Parenting the Hud

Postby Leeesaw » Thu Oct 07, 2010 2:12 am

BRILLIANT! Thanks so much! It works perfectly! :D
User avatar
Leeesaw
 
Posts: 20
Joined: Tue Sep 28, 2010 5:28 pm
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron