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

How to set autopilot altitude across various planes in MSFS 2020?

Messages
3
Country
unitedkingdom
Hi - I posted this question on the MSFS Forums a few days ago before I realised this forum existed.

I am attempting to set AP_ALT_VAR_SET_ENGLISH, or something equivalent to set autopilot altitude. It works fine on the default 747, but behaves differently on e.g. the default Cessna 172 G1000.

Here is the code:

simconnect.MapClientEventToSimEvent(EVENT_ID.ALT, "AP_ALT_VAR_SET_ENGLISH");
simconnect.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, EVENT_ID.ALT, 5000, EVENT_ID.GROUP, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);

simconnect.MapClientEventToSimEvent(EVENT_ID.ALTINC, "AP_ALT_VAR_INC");
simconnect.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, EVENT_ID.ALTINC, 100, EVENT_ID.GROUP, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);

When I run this code with the default Boeing 747 it works as expected, setting the altitude selector to 5000, then increasing it to 5100.

When I run this code with the default Cessna 172 G1000, AP_ALT_VAR_SET_ENGLISH will either increment or decrement the altitude by 1000, depending on the size of the value I set. The AP_ALT_VAR_INC does work on the Cessna.

Here’s what happens when I try to set these values using AP_ALT_VAR_SET_ENGLISH:
10 → decrements set altitude by 1000
100 → decrements by 1000
1000 → decrements by 1000
2000 → decrements by 1000
4000 → increments by 1000
10000 → increments by 1000
20000 → increments by 1000
40000 → increments by 1000

3000 does nothing and there seems to be smaller incremental changes for numbers near 3000 e.g. 2999.

I'm trying to get the ability to set the autopilot settings across as many planes as possible and so far am a bit stumped by setting altitude.
 
I'm guessing no replies means that this simple operation may be impossible for some planes. I guess I could use alt up and alt down buttons instead for those.
 
From the SDK:

KEY_AP_VS_VAR_SET_ENGLISH AP_VS_VAR_SET_ENGLISH Sets reference vertical speed in feet per minute

If, as the description states, it sets vertical speed then no, it doesn't work because VSHold has been fubar'd since FS2002 and I have no idea what the default 747 is playing at. The workround to get this to function is to set altitude hold to some unfeasible height for the aircraft if wanting a positive vertical speed and to zero feet if wanting a negative vertical speed. The following code snip then sets the required vertical speed.
Code:
if(vsi_target>0) trigger _key_event(KEY_AP_ALT_VAR_SET_ENGLISH,50000); //Positive VS
else trigger _key_event(KEY_AP_ALT_VAR_SET_ENGLISH,0); //Negative VS
trigger _key_event(KEY_AP_VS_VAR_SET_ENGLISH,(int)vsi_target); //Set required VS
trigger _key_event(KEY_AP_ALT_HOLD_ON,0); //Set alt hold on
It would be up to you to capture the required altitude as you get close to it. Some form of feedback loop would be ideal because you could code the reaction by aircraft weight.

Also; I have a very vague memory from FS2004 times that says AP_VS_VAR_SET_ENGLISH didn't work properly back then (i.e. as expected) and I'm guessing now it's because of the VSHold bug.
 
Last edited:
Ah right. That'll teach me not to cross-reference properly. I regret to say that the MSFS2020 is still incomplete, buggy and may not be working as expected. You may need to take that into consideration and code a workaround.
 
Back
Top