[SOLVED]Parenting Issue

Talk about making games.

[SOLVED]Parenting Issue

Postby DragonRift » Wed May 15, 2013 6:21 pm

Hello guys, I am trying to parent a thruster animation that needs to go in behind my actor but when I parent it, it goes over top of the actor.
I have tried changing its Zdepth but its not changing while parented, does anyone have a suggestion to fix this?
Last edited by DragonRift on Wed May 15, 2013 9:49 pm, edited 1 time in total.
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Parenting Issue

Postby Hblade » Wed May 15, 2013 6:23 pm

This is because when you parent something, it has the zdepth + the parents Z. The best way to do this would be to have a box do the moving, an invisible box (maybe a filled region or wireframe :D) and parent your player to the box, and instead of moving players X and Y move the boxe's, and then parent the thruster to that box, but make the players Z higher. :)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Parenting Issue

Postby DragonRift » Wed May 15, 2013 6:29 pm

Ok, I did that but now my actor is not changing the animation on keypress.

Code: Select all
char *key=GetKeyState();
int dir=key[KEY_RIGHT]-key[KEY_LEFT];
switch(dir)
  {
  //case 0: //None or Both
        //ChangeAnimation("Event Actor", "Player_Left", NO_CHANGE);
  //break;
 
  case -1: //Left
        x-=5;
        ChangeAnimation("Event Actor", "Player_Left", NO_CHANGE);
        break;
 
  case 1: //Right
        x+=5;
        ChangeAnimation("Event Actor", "Player_Right", NO_CHANGE);
  break;
}
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Parenting Issue

Postby DragonRift » Wed May 15, 2013 6:35 pm

I just noticed that when I fixed this, it unloaded my animations, problem is solved.

Another question is how do I do Up/Down?

Sorry, I am new to programming.
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Parenting Issue

Postby Hblade » Wed May 15, 2013 6:43 pm

instead of X to Y :)

y+=5 = down by 5 pixels
y-=5 = up by 5 pixels
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Parenting Issue

Postby DragonRift » Wed May 15, 2013 6:59 pm

My first script, I am so proud. :D

Code: Select all
char *key=GetKeyState();
int dir=key[KEY_RIGHT]-key[KEY_LEFT];
int fly=key[KEY_UP]-key[KEY_DOWN];

switch(dir)
  {
  case 0: //None or Both
        ChangeAnimation("Hover", "magneto_hover5x1_normal", NO_CHANGE);
  break;
 
  case -1: //Left
        x-=5;
        ChangeAnimation("Ship", "Concord_Left", NO_CHANGE);
        break;
 
  case 1: //Right
        x+=5;
        ChangeAnimation("Ship", "Concord_Right", NO_CHANGE);
  break;
}


switch(fly)
  {
  case 0: //None or Both
        ChangeAnimation("Hover", "magneto_hover5x1_normal", NO_CHANGE);
  break;
 
  case -1: //Down
        y+=3;
        ChangeAnimation("Hover", "magneto_hover5x1_weak", NO_CHANGE);
        break;
 
  case 1: //Up
        y-=2;
        ChangeAnimation("Hover", "magneto_hover5x1_strong", NO_CHANGE);
  break;
}
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: Parenting Issue

Postby Hblade » Wed May 15, 2013 7:05 pm

Looks amazing for first script! :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Parenting Issue

Postby DragonRift » Wed May 15, 2013 7:20 pm

I have this Thruster Animation that I want coming out the back of my ship when the key is pressed but I have to create this by code and have it in position and parented to the player. Any suggestions?

Code: Select all
switch(dir)
  {
  case 0: //None or Both
        ChangeAnimation("Hover", "magneto_hover5x1_normal", NO_CHANGE);
  break;
 
  case -1: //Left
        x-=5;
        ChangeAnimation("Ship", "Concord_Left", NO_CHANGE);
        //thruster animation here
        break;
 
  case 1: //Right
        x+=5;
        ChangeAnimation("Ship", "Concord_Right", NO_CHANGE);
        //thruster animation here
  break;
}


magneto_thruster1x5_magenta_thin_left.png
magneto_thruster1x5_magenta_thin_right.png
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: [SOLVED]Parenting Issue

Postby Hblade » Wed May 15, 2013 11:12 pm

Not sure, should be working
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: [SOLVED]Parenting Issue

Postby DragonRift » Wed May 15, 2013 11:19 pm

Hblade wrote:Not sure, should be working


Sorry, I already solved the issue, I was defining the variables as local variables instead of global variables which was causing an actor replication issue.
DragonRift
 
Posts: 70
Joined: Mon May 13, 2013 5:05 am
Score: 0 Give a positive score

Re: [SOLVED]Parenting Issue

Postby Hblade » Thu May 16, 2013 1:42 am

Ahh ok
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest