• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Animation Loop On/Off; Possible?

Messages
10,163
Country
us-arizona
Is there a way to make something 'loop-animate' and have a on/off switch attached to the code?

We have Tick18, but nothing stops that.

Lets say I wish to have something start spinning when I hit a switch, continuous, single speed.

Any idea's from the gurus of the code realms?
 
Don't use Tick18 to drive the animation. Create your own custom L:var,unit instead.

The following is for an XML "gauge," but should be easily modifiable for use by a 3d object via modeldef.xml or MakeMLD.parts.xml script:
Code:
<Gauge Name="Fan Gauge" Version="1.0">
  <Image Name="Fan-Backing.bmp" ImageSizes="286,286"/>
  <Element>
    <Position X="0" Y="0"/>
    <MaskImage Name="Fan-Mask.bmp">
      <Axis X="143" Y="143"/>
    </MaskImage>
    <Image Name="FanBlades.bmp" Luminous="Yes">
      <Axis X="128" Y="128"/>
    </Image>
    <Rotate>
      <Value>
        <!-- The speed of the rotation may be adjusted by 
                      the multiplier following the (L:Fan,enum) variable up to 100 max!-->
        (L:Fan,enum) 100 * /-/
      </Value>
    </Rotate>
  </Element>

  <!-- The script below will reset the (L:Fan,enum) variable to 0 if greater than 3600 -->
  <Element>
    <Select>
      <Value>
        (L:Fan,enum) 360 >
        if{ 0 (>L:Fan,enum) }
      </Value>
    </Select>
  </Element>

  <!-- The script below will increment the (L:Fan,enum) variable from 0 to 360 -->
  <Element>
    <Select>
      <Value>
        (L:FanSwitch,bool) 1 ==
        if{ (L:Fan,enum) ++ (>L:Fan,enum) }
      </Value>
    </Select>
  </Element>

  <Element>
    <Position X="0" Y="0"/>
    <Image Name="FanShroud.bmp"/>
  </Element>
</Gauge>
 
“Is there a way to make something 'loop-animate' and have a on/off switch attached to the code?”

In FS2004 I use this for my rotating beacon “motor” to drive the reflector:

Code:
<!-- rotating beacon motor-->

<part>
  <name>revolve</name>
   <animation>
     <rotation>Z</rotation>
    <parameter>
      <code>(L:revolve,bool) 1 == if{ (E:ABSOLUTE TIME, second) 360 * dgrd } els{ 0 }</code>
    </parameter>
   </animation>
</part>

The above is a non-keyframed part; just adjust the axis to suit your needs.

For a 3D non-keyframed switch

Code:
<part>
    <name>rot_bcn_sw</name>
    <animation>
     <rotation>X</rotation>
    <parameter>
      <code>(L:beaconsw, bool) 0.6 *</code>
    </parameter>
   </animation>

    <mouserect>
        <cursor>Hand</cursor>
        <tooltip_text>Rotating Beacon (%((L:beaconsw,bool))%{case}%{:0}OFF)%{:1}ON%{End})</tooltip_text>
         <mouse_flags>LeftSingle</mouse_flags>
          <callback_code>
	(L:beaconsw,bool) ! (>L:beaconsw,bool) (L:revolve, bool) ! (>L:revolve, bool)
  </callback_code>
 </mouserect>
</part>
My rotating beacon switch is tied into a circuit breaker, and the mouse stuff gets a little complicated, so to avoid confusion I changed the callback code above to simply animate the switch and start/stop the rotation.
 
Awesome. Many thanks guys.

I remember asking this many years ago and no one had an answer. Great to see that its doable now.

Thanks again,


Bill
 
SOLUTION; Looped key framed animation of an rotating disk, with on/off swith now WORKING...

I tryed out this for a key framed animation ( An Ventilation rotor in the VC Roof, with an on/off switch on the Dashboard ) for FSX & P3D modeldef.xml, and it did not Work for Me even seach and try out many suggestions...

But I wanted it to Work as I did not like the TicK18/Ambient Params. You cannot create a working switch ( At least I could not ) for the Ambient animation, and the rotation speed is also to slow for a Ventilator Rotor after My opinion.

After working hard 3 very long days 15-16 hours each ( Even thought about create the rotor objeckt as an effect ) I had My Heruka :)

Because of all the help I found here on this forum from both Arno and other users, I decided to share this XML code here free to use both for freeware as well as commersial use.

The Switch code is quite simple and can be used for any kind of switches ( Actualle I spend a lot of time on that get it working, before I found an almost identically code here.

Because its only the swith wich has an "Lag" parameter, not the actual rotating object, Theres a small delay in the retracting of the switch, maybee anyone here can improve the XML code? But feel free to use it, just credit Me as I credit for the help I get, especially Bill Leaming, from wich's "3 Speed Wiper" animation XML souce code, I got the inspiration to the finally solution ;-)

The looping code of the rotating objeckt can be used to loop any key framed animation as well...

Code:
    <Animation name="Ventilation_Switch" guid="80AAE78A-E159-463b-A9EC-6672BA0ED196" length="100" type="Sim" typeParam2="Ventilation_Switch" typeParam="AutoPlay" />

  <PartInfo>
    <Name>Ventilation_Switch</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:Ventilation_Switch,number) 100 *
        </Code>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle</MouseFlags>
    <TooltipText>Ventilation Switch</TooltipText>
      <CallbackCode>
        (L:Ventilation_Switch) ! (&gt;L:Ventilation_Switch)
      </CallbackCode>
    </MouseRect>
  </PartInfo>

      <Animation name="ventilation_Anim" guid="A958CDE7-9FFE-4c33-A5EC-605563F5025F" length="100" type="Sim" typeParam2="ventilation_Anim" typeParam="AutoPlay" />

<PartInfo>
  <Name>ventilation_Anim</Name>
    <AnimLength>100</AnimLength>
      <Animation>
        <Parameter>
         <Code>
        (L:Ventilation_Switch,number) 100 *
          if{ (L:Ventilation_Switch) 100 * != (L:Ventilation_Switch) 1 &gt; or
             if{ (L:Ventilation_Switch) (L:Ventilation_Switch) 0.75 * + 100 % d (&gt;L:Ventilation_Switch) }
          els{ (&gt;L:Ventilation_Switch) }        
          </Code>
      </Parameter>
  </Animation>
</PartInfo>

Images from ongoing update of the Piper Pa28-140

Ventilator off FSX

Ventilator on FSX

Ventilator_0ff P3D

Ventilator_on P3D


Sincerely Regards

Claus V. Holmberg / SCANSIM Flightsimulation
 
Last edited:
If You just wan an keyframed animtion for and objeckt as well as the on/off switch without looping, heres another example wich can be used for any animated object with a switch to start and stop the animation...

Code:
    <Animation name="switch_cabin_heat" guid="BC4DDB66-F7AB-4eb3-8CCE-43DD216DE7A8" length="50" type="Sim" typeParam2="switch_cabin_heat" typeParam="AutoPlay" />

  <PartInfo>
    <Name>switch_cabin_heat</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:switch_cabin_heat,number) 50 *
        </Code>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle</MouseFlags>
      <CallbackCode>
        (L:switch_cabin_heat) ! (&gt;L:switch_cabin_heat)
      </CallbackCode>
    </MouseRect>
  </PartInfo>

    <Animation name="cabin_heat_Disk" guid="3F965545-01BF-418d-A8D3-B42AAB283DB2" length="100" type="Sim" typeParam2="cabin_heat_Disk" typeParam="AutoPlay" />

  <PartInfo>
    <Name>cabin_heat_Disk</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:switch_cabin_heat) 100 *
        </Code>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
  </PartInfo>
 
Last edited:
With a Little help from Taguilo, the code now looks like this, and can be used for any kind of looping an non ambient animation...

Code:
    <Animation name="Ventilation_Switch" guid="80AAE78A-E159-463b-A9EC-6672BA0ED196" length="100" type="Sim" typeParam2="Ventilation_Switch" typeParam="AutoPlay" />

  <PartInfo>
    <Name>Ventilation_Switch</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:Ventilation_Switch,number) 100 *
        </Code>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <MouseFlags>LeftSingle</MouseFlags>
    <TooltipText>Ventilation Switch</TooltipText>
      <CallbackCode>
        (L:Ventilation_Switch) ! (&gt;L:Ventilation_Switch)
      </CallbackCode>
    </MouseRect>
  </PartInfo>

      <Animation name="ventilation_Anim" guid="A958CDE7-9FFE-4c33-A5EC-605563F5025F" length="100" type="Sim" typeParam2="ventilation_Anim" typeParam="AutoPlay" />

<PartInfo>
   <Name>ventilation_Anim</Name>
   <AnimLength>100</AnimLength>
   <Animation>
         <Parameter>
             <Code>
                 (L:Ventilation_Switch,number)  (L:Ventilation_status,number)  1 &gt; or
                 if{ (L:Ventilation_status,number) (L:Ventilation_Switch) 2.0 * + 100 % d (&gt;L:Ventilation_status,number) }
                 els{ 0 (&gt;L:Ventilation_status,number) }
             </Code>
        </Parameter>
   </Animation>
</PartInfo>

/Claus
 
Back
Top