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

Custom interactive animation

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hello again,

how can I code the following:
I want to have a 3D lever in the VC and by turning it, a part on the outside of the aircraft should turn as well.

I made the two <Animation name> entry in the modeldef file. Here is the partname for the outside part:

Code:
  <PartInfo>
    <Name>rotating part</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Sim>
          <Variable>Rotating Variable</Variable>
          <Units>degrees</Units>
          <Scale>36</Scale>
        </Sim>
        <Lag>400</Lag>
      </Parameter>
    </Animation>
  </PartInfo>

But I have no idea how to program the lever.

Any ideas?

Regards from Aotearoa
Vitus
 
*bump*

In the SDK is an example for "CallbackDragging" which is basically what I want to use: The user can move the lever by clicking&dragging it.
BUT: the example code triggers a KeyEvent - however I want to modify a L: variable!

I have no idea... :confused:

Vitus
 
I just finished the artwork for my fuel selectors and as I can't use the default fuel tank key events due to the uncommon fuel system of the Electra, I have a similar problem here.

I want the selectors be movable by drag-and-drop but then snapping to the nearest of four (or five) positions and by that, changing the value of the corresponding enum L: variable.

Come on guys! I know you program stuff like that every day! :cool:

Regards
Vitus
 
....... I will keep asking until the question is solved. :p



What I was able to figure out is, how to make an animated part that reacts depending on the value of a L:variable.

But I am still not able to set these value with drag&drop of a lever.


Sooooooo: please give me a hint!
Vitus
 
Pop over to ffds, and grab the custom code for a drag lever. That will allow you to create the lever, then just use the exact same name for the external part. That should give you exactly what you want.
 
Hi there,

I haven't produced any working code yet, but after reading the different threads in the FFDS forum and browsing through the default modeldef.xml, I think I understood the idea!

Thanks for your help - I will post a snippet here after I finally manage to implement a working example.

Regards
Vitus
 
Hi there,

I promised to post something as soon as I figure it out. Because I highly participated on the tons of examples in the FFDS forum, I decided to write contribute something to this knowledge base and wrote a few lines on that topic. You can find my posting here.

But in short, here is my working code:
Code:
<PartInfo>
  <Name>big_lever</Name>
  <AnimLength>100</AnimLength>
  <Animation>
    <Parameter>
	<Code>
	  (L:BIG LEVER,number)
	</Code>
	<Lag>400</Lag>
    </Paramter>
  </Animation>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <TooltipText>This is a big lever!</ToolTipText>
    <MouseFlags>LeftSingle+LeftDrag</MouseFlags>
    <CallbackCode>
	(M:Event) 'LeftSingle' scmp 0 ==
	if{
	  (M:X) (&gt;L:MOUSEPOS, number)
	  quit
	}
	(M:Event) 'LeftDrag' scmp 0 ==
	if{
	  (M:X) (L:MOUSEPOS,number) - 0.1 * (L:BIG LEVER,number) + (&gt;L:BIG LEVER,number)
	  (M:X) (&gt;L:MOUSEPOS,number)
	  (L:BIG LEVER,number) 0 &lt;
	  if{
	    0 (&gt;BIG LEVER,number)
	    quit
	  }
	  (L:BIG LEVER,number) 100 &gt;
	  if{
	    100 (&gt;BIG LEVER,number)
	    quit
	  }
	}
    </CallbackCode>
  </MouseRect>
</PartInfo>

Regards
Vitus
 
Well done sir!

The best advice you've given is this, IMHO:

Instead of using lever-specific variables for the mouse status like Mariopilot does, I propose that you just define one MOUSEPOS variable for all your levers. Its better organized and this also makes your life easier regarding your copy & paste actions.

Amen! Reusable, generic variables are always the best approach. You can only move one lever at at a time anyway, so there'd never be a conflict... :D
 
Thanks! I had very good advisers! :D

I would love to have a second Mouse and a second Cursor on the screen. But until then one Mouse position variable is enough :rolleyes:

Vitus
 
Back
Top