Question How to set up automatic animation

xjflcf520

Member
Joined
Feb 26, 2021
Messages
70
Reaction score
6
Points
23
Location
Chana
for example, when the aircraft takes off to a certain height, the landing gear can automatically retract.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,605
Reaction score
2,327
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
Yes, can I do this in module of making spacecraft with c++

Well, then you need two ingredients:
  1. The trigger: You need to check in clbkPrestep (or clbkPostStep), if you reached a certain altitude. If you exceeded this you trigger the gear up event. A trigger is a finite state machine with two states (reset <-> triggered) in the sense of programming: Once you triggered it, the check does no longer need to be executed until the trigger is reset, so the following event only gets triggered once (and does not prevent you from deploying landing gear for landing).
  2. The animation: Like if you react on a keypress, you need to set the animation state in the clbkPrestep. Luckily. Orbiter comes with a simple AnimState class that contains a lot of standard code for such simple animations.

The trigger can, in pseudo code (OK, its Inform7) for example look like this:

If gearUpTrigger is reset and getAltitude() > 500.0:
Now gearUpTrigger is triggered;
Now gearCommand is up;
endif.

(I don't want to write C++ code here for a reason: Its your add-on, you should control its implementation. Don't make a Frankenstein module from various code snippets copied around from the forum, for the sake of your own sanity.)
 
Last edited:

xjflcf520

Member
Joined
Feb 26, 2021
Messages
70
Reaction score
6
Points
23
Location
Chana
Well, then you need two ingredients:
  1. The trigger: You need to check in clbkPrestep (or clbkPostStep), if you reached a certain altitude. If you exceeded this you trigger the gear up event. A trigger is a finite state machine with two states (reset <-> triggered) in the sense of programming: Once you triggered it, the check does no longer need to be executed until the trigger is reset, so the following event only gets triggered once (and does not prevent you from deploying landing gear for landing).
  2. The animation: Like if you react on a keypress, you need to set the animation state in the clbkPrestep. Luckily. Orbiter comes with a simple AnimState class that contains a lot of standard code for such simple animations.

The trigger can, in pseudo code (OK, its Inform7) for example look like this:

If gearUpTrigger is reset and getAltitude() > 500.0:
Now gearUpTrigger is triggered;
Now gearCommand is up;
endif.

(I don't want to write C++ code here for a reason: Its your add-on, you should control its implementation. Don't make a Frankenstein module from various code snippets copied around from the forum, for the sake of your own sanity.)
Thank you very much for your detailed answers. I have some ideas
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,278
Reaction score
3,247
Points
203
Location
Toulouse
But don't be afraid to check how it is done in SDK samples, reverse-engineering code and fitting it to your needs is an essential part of learning. Then, with experience, you'll start making links between concepts.
 
Top