Page 1 of 1

[SOLVED]Parenting Issue

PostPosted: Wed May 15, 2013 6:21 pm
by DragonRift
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?

Re: Parenting Issue

PostPosted: Wed May 15, 2013 6:23 pm
by Hblade
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. :)

Re: Parenting Issue

PostPosted: Wed May 15, 2013 6:29 pm
by DragonRift
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;
}

Re: Parenting Issue

PostPosted: Wed May 15, 2013 6:35 pm
by DragonRift
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.

Re: Parenting Issue

PostPosted: Wed May 15, 2013 6:43 pm
by Hblade
instead of X to Y :)

y+=5 = down by 5 pixels
y-=5 = up by 5 pixels

Re: Parenting Issue

PostPosted: Wed May 15, 2013 6:59 pm
by DragonRift
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;
}

Re: Parenting Issue

PostPosted: Wed May 15, 2013 7:05 pm
by Hblade
Looks amazing for first script! :D

Re: Parenting Issue

PostPosted: Wed May 15, 2013 7:20 pm
by DragonRift
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

Re: [SOLVED]Parenting Issue

PostPosted: Wed May 15, 2013 11:12 pm
by Hblade
Not sure, should be working

Re: [SOLVED]Parenting Issue

PostPosted: Wed May 15, 2013 11:19 pm
by DragonRift
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.

Re: [SOLVED]Parenting Issue

PostPosted: Thu May 16, 2013 1:42 am
by Hblade
Ahh ok