Adopting parents animpos

Game Editor comments and discussion.

Adopting parents animpos

Postby Troodon » Sat May 19, 2012 10:23 am

Hi,
I have a fighter plane's core that rotates around itself smoothly 360 degrees. Then I have smaller actors installed on it, engines and weapons and such. They have also 360 degrees rotation and the plane's core is their parent. It worked fine in first testings, the plane rotated 360 degrees and the pieces on board rotated around it so that it looked like they were physically sitting on it. I used the code line (in global code):

animpos = fighter_core.animpos;

for the pieces onboard.

The game mechanic anyway needs to support fleets of fighter planes so I changed that part of the code into:

animpos = parent.animpos;

Then I tested in game mode again but this time, the pieces don't move anymore with the plane! When I turn the nose left or right, the pieces just stay in the same position of the animation, making them just float in the air.

Question in short: How can I make the pieces follow their parent actors animpos?

Thank you :)
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Adopting parents animpos

Postby savvy » Sat May 19, 2012 1:32 pm

You have done it right, it owuld be
Code: Select all
animpos=parent.animpos;
Maybe the parent isn't being assigned properly?

EDIT: are the parts being created by the thing its parented to? if so you could/should try using
Code: Select all
animpos=creator.animpos;


savvy
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: Adopting parents animpos

Postby Troodon » Sat May 19, 2012 9:04 pm

The parent-relation is assigned when the actors are created. And yes, they are created by the parent actor.

I tried to change parent to creator but the problem persisted.
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Adopting parents animpos

Postby skydereign » Sat May 19, 2012 10:31 pm

If the ship parts are indeed parented to the the actual ship, your code should work. Easy way to tell is move the ship actor, if the parts move they are parented. Since they aren't rotating properly, it sounds like they are parented to the wrong actor (or a non-existent actor).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Adopting parents animpos

Postby Troodon » Sun May 20, 2012 9:53 am

The parent-relation is assigned in the fighter_core -> create actor -> script editor as:

CreateActor("fighter_engine1", "A_fighter_engine1", "Event Actor", "(none)", 0, 0, false);

for each. Tried also "Creator Actor" instead of "Event Actor" but didn't help.

When I move the ship actor, the parts move with it. They just don't change their animpos to the ship's animpos.
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Adopting parents animpos

Postby savvy » Sun May 20, 2012 1:01 pm

This is strange.
Have you use ChangeAnimationDirection on the turrets? if the animation direction isn't changed to stop then this will cause it to do what is happening here.

savvy
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: Adopting parents animpos

Postby Troodon » Sun May 20, 2012 1:59 pm

Yes, their animations are stopped when they are created.
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Adopting parents animpos

Postby Bee-Ant » Sun May 20, 2012 3:23 pm

fighter_core -> Create Actor:
Code: Select all
CreateActor("fighter_engine1", "A_fighter_engine1", "Event Actor", "(none)", 0, 0, false);


fighter_engine1 -> Draw Actor:
Code: Select all
char str[32];
Actor *get;
sprintf(str,"fighter_core.%i",cloneindex);
get=getclone(str);
animpos=get->animpos;
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Adopting parents animpos

Postby Troodon » Sun May 20, 2012 4:22 pm

I wouldn't mind some explanations Bee :P

ChangeParent("fighter_engine1", "Event Actor"); <- Wouldn't this make every fighter_engine1 child of the created fighter_core?

Also, what's happening in that draw actor code?

It creates an char variable array with 32 slots? And then gets every actor? And then inputs the characters of "fighter_core.%i" in the variable? And uses that number to chose the clone? All this to choose who's animpos the engine is using?

Why oh why? And what's wrong with just using animpos = creator.animpos?
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Adopting parents animpos

Postby Bee-Ant » Sun May 20, 2012 4:39 pm

Troodon wrote:ChangeParent("fighter_engine1", "Event Actor"); <- Wouldn't this make every fighter_engine1 child of the created fighter_core?

I did an edit on my previous post.

Troodon wrote:It creates an char variable array with 32 slots? And then gets every actor? And then inputs the characters of "fighter_core.%i" in the variable? And uses that number to chose the clone? All this to choose who's animpos the engine is using?

Troodon wrote:The parent-relation is assigned when the actors are created. And yes, they are created by the parent actor.

fighter_engine is created when fighter_core is created right?
Since they're clones, that means:
- fighter_core.0 will create fighter_engine.0
- fighter_core.1 will create fighter_engine.1
- etc
Why I use char str[32]? to get the parent name in name.cloneindex format (do I have to explain what cloneindex is?).
And it's not "gets every actor", but "gets assigned actor only".
The outcome of sprintf(str, "fighter_core.%i", cloneindex); is decided by the each fighter_engine cloneindex. fighter_engine with 9 cloneindex will get "fighter_core.9" output, fighter_engine with 4 cloneindex will get "fighter_core.4" output.
And we use getclone(str); to create a link to the clone (in this case the parent) that's it's name is stored within str.
And then assign parent's attribute to the child with animpos=get->animpos;

Actually using a mere animpos=parent.animpos; in DrawActor will get the job done. But since it doesn't work (in your case), so I provide another way to solve that.
One thing to note, avoid assigning local variables in Global code.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Adopting parents animpos

Postby Troodon » Sun May 20, 2012 6:04 pm

:roll:

I'll give it a try later but I still feel weird about it not working in the simple way. Could it be a bug that would get fixed if I just rebuild the ged file from the beginning?

I remember there was some bug related to the parent-child thing but can't recall it..maybe about the z level?
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Re: Adopting parents animpos

Postby skydereign » Sun May 20, 2012 7:31 pm

Troodon wrote:I remember there was some bug related to the parent-child thing but can't recall it..maybe about the z level?

What I think you are talking about isn't a bug, that is a feature. I can get the code to work properly with just what we discussed here. So I don't think it is a bug, but rather something in your setup that is messing with hit. Can you replicate it not working in a small ged (with just the ship and attachments)?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest