Beginner - How to create default toggle animations

For topics related to the creation of simulation objects (SimObjects). This includes development of aircraft, ground, and maritime vehicles.
Post Reply
iko
Posts: 5
Joined: Tue Jun 23, 2020 5:31 pm

Beginner - How to create default toggle animations

Post by iko »

Hi,

I'm new to the entire Prepar3D SIM and especially the SDK.
I'm creating animations for a new aircraft and I've got the hang of how to use the default settings but not how to create my own "PartInfo".

I have an active thread over at FSDeveloper(https://www.fsdeveloper.com/forum/threa ... 3d.447938/) but I'm not getting the answers to get me further so I'm asking here as well.

My issue:
I can't see my custom animation move within P3D. If I tag the animation as something else (default like doors, Shift+E) it works.

I've tried to use the default modeldef.xml and the wing fold toggle (T) but it won't work either.

I've tried to create my own name and GUID but still use the WING FOLD variable and it still won't work. What am I doing wrong and is there a simple "code" I can use instead to just toggle an animation?

Code: Select all

<Animation name="thrust_reversor" guid="99510169-9693-4e44-8bd5-8e739bef0d07" length="100" type="Sim" typeParam2="thrust_reversor" typeParam="AutoPlay" />

Code: Select all

<PartInfo>
        <Name>thrust_reversor</Name>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Sim>
                    <Variable>WING FOLD:0</Variable>
                    <Units>percent</Units>
                </Sim>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <EventID>TOGGLE_WING_FOLD</EventID>
        </MouseRect>
    </PartInfo>
Thanks!
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: Beginner - How to create default toggle animations

Post by Clifton Crane »

Hi iko,

"WING FOLD" is not a valid simulation variable. You may want to try the following in your <Variable> tag:

FOLDING WING LEFT PERCENT:1
FOLDING WING RIGHT PERCENT:1

Also, the aircraft that you are testing with will likely need to have folding wings configured in the aircraft.cfg in order to trigger the animation.

Hope this helps!

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
iko
Posts: 5
Joined: Tue Jun 23, 2020 5:31 pm

Re: Beginner - How to create default toggle animations

Post by iko »

Clifton Crane wrote: Tue Jun 23, 2020 6:59 pm Hi iko,

"WING FOLD" is not a valid simulation variable. You may want to try the following in your <Variable> tag:

FOLDING WING LEFT PERCENT:1
FOLDING WING RIGHT PERCENT:1

Also, the aircraft that you are testing with will likely need to have folding wings configured in the aircraft.cfg in order to trigger the animation.

Hope this helps!

Regards,
Clifton
Thank you!

Like this?

Code: Select all

<PartInfo>
        <Name>thrust_reversor</Name>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Sim>
                    <Variable>FOLDING WING LEFT PERCENT:1</Variable>
                </Sim>
            </Parameter>
        </Animation>
        <MouseRect>
            <Cursor>Hand</Cursor>
            <EventID>TOGGLE_WING_FOLD</EventID>
        </MouseRect>
    </PartInfo>

It still didn't work so I might need to add it in the "Aircraft.cfg". I didn't see anything about wing fold within the CFG.
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: Beginner - How to create default toggle animations

Post by Clifton Crane »

Hi iko,

You'll want to add the <Units>percent</Units> property back. This will return the wing fold in the range 0-100, which will match your animation key frames.

By default, that simulation variable would return "percent over 100", which would return the value in the range 0.0 to 1.0, which wouldn't animate correctly.

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
iko
Posts: 5
Joined: Tue Jun 23, 2020 5:31 pm

Re: Beginner - How to create default toggle animations

Post by iko »

Hi Clifton,

Thank you!

I can get it to work if I use the "wing_fold_l_pct" animation name, but can I change the name?

If I keep everything and only changes the name it wont work anymore. (I've changed it in both <Animation and <PartInfo). I've also tested to use the same GUID but with new name.

I would like at least three or four unique animations to be able to activate.
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: Beginner - How to create default toggle animations

Post by Clifton Crane »

Hi iko,

If you wanted to create a new animation I would first add a new <Animation /> element with unique "name" and "GUID". You will also want to make sure that "typeparam2" matches the "name" attribute. Then you would also create new <PartInfo> section with a name that matches the new <Animation /> element (you could base this on an existing animation and update as needed). After you have added the animation to the modeldef.xml, you will also need to rebind that animation to the 3D model part in 3dsMax.

Note that the variable used in the PartInfo section is what will drive the animation. Simply creating new animations based on the same <Variable> will not create unique animations as they will all be driven by the same variable.

I noticed in your post your animation name is "thrust_reversor". The default modeldef.xml contains animation definitions for up to 4 engines. See the "thrust_rev" animation.

Hope this helps!

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
iko
Posts: 5
Joined: Tue Jun 23, 2020 5:31 pm

Re: Beginner - How to create default toggle animations

Post by iko »

Clifton Crane wrote: Mon Jun 29, 2020 12:56 pm Hi iko,

If you wanted to create a new animation I would first add a new <Animation /> element with unique "name" and "GUID". You will also want to make sure that "typeparam2" matches the "name" attribute. Then you would also create new <PartInfo> section with a name that matches the new <Animation /> element (you could base this on an existing animation and update as needed). After you have added the animation to the modeldef.xml, you will also need to rebind that animation to the 3D model part in 3dsMax.

Note that the variable used in the PartInfo section is what will drive the animation. Simply creating new animations based on the same <Variable> will not create unique animations as they will all be driven by the same variable.
Hi,
Sorry for the late response but I didn't (and still havn't) get it to work so I started with texturing and other work in the mean time. Now I'm back at this again...

I understand the basics of how it works and how most of it connects but I still can't get it to work.

I can get the "wing_fold_l_pct" to work but that's it (except for all the basic, flaps, gear e.t.c.).
I've tried "sling_hoist_percent_deployed", "switch_hoist_raise", "switch_hoist_lower", "switch_anti_ice_eng0"(works but toggles hard, without transition), "l_float" and "l_water_rudder_key" / "r_water_rudder_key".

This is what I had to add in the Aircraft.cfg to get the wings fold to work:

Code: Select all

[folding_wings]
wing_fold_system_type = 3
fold_rates = 0.05, 0.05






For example, now I'm trying to add the animations to "water rudder" (CTRL+W) but they wont work.

Code: Select all

    <Animation name="l_water_rudder_key" guid="CE0B48AA-EB61-4afc-A59C-3612D27E9F53" type="Sim" typeParam2="l_water_rudder_key" typeParam="AutoPlay" />

Code: Select all

<PartInfo>
	    <Name>l_water_rudder_key</Name>
	    <AnimLength>100</AnimLength>
	    <Animation>
		    <Parameter>
			    <Sim>
				    <Variable>WATER LEFT RUDDER EXTENDED</Variable>
				    <Units>keyframe</Units>
			    </Sim>
		    </Parameter>
	    </Animation>
    </PartInfo>
I downloaded a free float plane for P3D to test if my binding was wrong some how and it wasn't. It works well on that model.

I thought that I might need to add something in the Aircraft.CFG as well but I can't find anything related to water rudder within the aircraft.cfg for the downloaded float plane.


Clifton Crane wrote: Mon Jun 29, 2020 12:56 pm I noticed in your post your animation name is "thrust_reversor". The default modeldef.xml contains animation definitions for up to 4 engines. See the "thrust_rev" animation.
Yes I know, but we don't want to use those. They don't connect well with our simulator.
Post Reply