• 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.

MSFS Common problem with rotating knobs

Messages
531
Country
france
Hello experts,

I am not an expert in virtual cockpit animations and I am facing a problem that I believe is very common:
I created an animation for a rotating knob that controls a local variable that varies from 0 to 359 degrees, and like the HEADING or COURSE knob in many cockpits, it can turn endlessly in both directions. Turning clockwise increases the value and when the value reaches 360, it is reset to 0 and can keep increasing. Same for anticlockwise, decreasing.
The XML code in the interior model file looks like this:

<Component ID="MyCompenentID" Node="MyNode">
<Update Frequency="2.0">
(O:IsInit) ! if{ 1 (&gt;O:IsInit) 0 (&gt;L:MyLocalVariable, number) }
</Update>
<UseTemplate Name="ASOBO_GT_Knob_Finite_Code">
<ANIM_NAME>My_Rotating_Knob</ANIM_NAME>
<ANIM_CODE>(L:MyLocalVariable, number) 1 *</ANIM_CODE>
<ANIMTIP_0>OFF</ANIMTIP_0>
<ANIMTIP_1>AUTO</ANIMTIP_1>
<ANIMTIP_2>ON</ANIMTIP_2>
<ANIM_LENGTH>360</ANIM_LENGTH>
<CLOCKWISE_CODE>
(L:MyLocalVariable, number) ++ d 359 &gt; if{ 0 } (&gt;L:MyLocalVariable, number)
</CLOCKWISE_CODE>
<ANTICLOCKWISE_CODE>
(L:MyLocalVariable, number) -- d 0 &lt; if{ 359 } (&gt;L:MyLocalVariable, number)
</ANTICLOCKWISE_CODE>
</UseTemplate>
</Component>

It works well, but... When I turn the knob clockwise using the mouse wheel and reach the value of 359, increasing once more resets it to 0. The value is correct, but the animation is wrong because the knob turns counterclockwise to reflect the value of 0. It is the same the other when I decrease and reach the value of 0, decreasing again sets the value to 359 and the animation is wrong.
The strange thing is that if I use the mouse button of the left/right of the knob to decrease/increase the value, everything works perfectly.
I am sure it is a common problem some of you already had, I am sure there is solution.

Thanks for any help,
Eric
 
Hi,
How many keyframes are used for 0 to 360 ° ? I create in such occasion, 5 keyframes: 0, 90, 180, 270, 360
 
The code I copied here is simplified. In my code I have 36 key frames, which means the knob turns 10° for each increment/decrement. But it doesn't change the problem...

Let's say I use the same technique as you do, with 5 key frames, how would it solve my problem? My understanding is that the problem remains the same: when you increase the value a change from 5 to 0, the knob will turn counter clockwise as if you set it to 0. Am I wrong?

Eric
 
Is there a infinite_code template? Because an infinite knob is one that continuously rotates. Finite implies there are limits. The roll back to keyframe zero implies there is a <Lag> parameter in the animation in the template as this is a common issue with lag and animations.
 
As Anthony, I'm guessing the ASOBO_GT_Knob_Finite_Code is propagating an <ANIM_LAG> value other than 0 down through the sub-templates, probably ending up in Asobo_GT_Anim. Maybe try adding <ANIM_LAG>0</ANIM_LAG> as another parameter into the ASOBO_GT_Knob_Finite_Code (no guarantees, it completely depends how that template is written), or find another template.
 
I don't understand, I wrote a reply after Anthony's post and I don't see it now, was it deleted?
Anyway, I was saying that setting ANIM_LAG to 0 solved the problem, and I thank Anthony for his help.

Now I saw that both finite and infinite templates have ANIM_LAG set to 100, but if I set it to 0 in my component, it overrides the value defined in the template and it works :)
 
if I set it to 0 in my component, it overrides the value defined in the template and it works
Yes, it is the normal functioning of a template:
- propose default values and
- in the instantiation overload the desired values to adapt to its need
 
Back
Top