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

FSXA Simple Visibility Code Not Working ... RESOLVED

Milton_Shupe

Resource contributor
Messages
331
Country
us-newmexico
This is essentially code from another part in modeldef I applied to two copies of a turret, one animated, one not. (Reason for two is it uses Ambient as the tag.) I would like to see the animated turret kick in after 125 knots.

Anyone see a reason why this should not work.

I am seeing both turrets in game, one animated, one not.


Code:
<!-- TURRET Animation based on in-flight for FSX -->
    <PartInfo>
        <Name>animate_turret</Name>
        <VisibleInRange>
            <Parameter>
                <Sim>
                    <Variable>RELATIVE WIND VELOCITY BODY Z</Variable>
                    <Units>knots</Units>
                </Sim>
            </Parameter>
            <MinValue>125</MinValue>
        </VisibleInRange>
    </PartInfo>
   
    <PartInfo>
        <Name>noanimate_turret</Name>
        <VisibleInRange>
            <Parameter>
                <Sim>
                    <Variable>RELATIVE WIND VELOCITY BODY Z</Variable>
                    <Units>knots</Units>
                </Sim>
            </Parameter>
            <MaxValue>125</MaxValue>
        </VisibleInRange>
    </PartInfo>

Thanks in advance for any insights.
 
Milton, normally one would use a simpler <Visibility> condition, perhaps something like --

Code:
<PartInfo>
<Name>animate_turret</Name>   
<Visibility>
<Parameter>
<Code>
(A:RELATIVE WIND VELOCITY BODY Z, knots) 125 &gt;=
</Code>
</Parameter> 
</Visibility>
</PartInfo>

and for the noanimate version the condition would be

(A:RELATIVE WIND VELOCITY BODY Z, knots) 125 &lt;

I'm not really familiar with the A: variable you are referencing here, (A:AIRSPEED INDICATED, knots) would be a possible alternative I guess.

PS a really simple way to test the general validity of this code would be to provisionally replace the condition by "(A:LIGHT NAV, Bool) 0 ==" and "(A:LIGHT NAV, Bool) 1 ==" respectively. Then if you turn the lights off/on, the effect should show.
 
Last edited by a moderator:
Ah, thank you Sir :) Will give it a go and report back.

EDIT: Okay, with the revised code and proper Visibility tags, she works as required. Thank you mjahn. :)
 

Attachments

  • ms-2017-oct-10-001.jpg
    ms-2017-oct-10-001.jpg
    141.5 KB · Views: 429
  • ms-2017-oct-10-005.jpg
    ms-2017-oct-10-005.jpg
    88.6 KB · Views: 448
  • ms-2017-oct-10-006.jpg
    ms-2017-oct-10-006.jpg
    117.9 KB · Views: 353
  • ms-2017-oct-10-007.jpg
    ms-2017-oct-10-007.jpg
    130 KB · Views: 465
Last edited:
Code:
<!-- TURRET Animation based on in-flight for FSX -->
    
    <PartInfo>
    <Name>animate_turret</Name>   
        <Visibility>
            <Parameter>
                <Code>
                (A:AIRSPEED INDICATED, knots) 125 &gt;=
                </Code>
            </Parameter>
        </Visibility>
    </PartInfo>
    
    <PartInfo>
        <Name>noanimate_turret</Name>
        <Visibility>
            <Parameter>
                <Code>
                (A:AIRSPEED INDICATED, knots) 125 &lt;
                </Code>
            </Parameter>
        </Visibility>
    </PartInfo>

Hi Paul; happy to see you are settled in now and posting away. :) Sorry I didn't get to see you this trip.

Yes, Sir, once the code was corrected, the objects showed up in the Visibility tags and I was good to go.
 
Speaking of turrets, I have five (!) of them to take care of, and I want each of them to be manually operated in horizontal as well as vertical sweeps. So far I have managed to implement this via a 2D gauge, which I am happy to share if there is any interest for it. I can mouse-click left to stepwise swivel left 36 degs, and click right to go the other way round, and use the mouse wheel to go up and down. So far so good.

What I really want, however, is to use three or four joystick buttons to go up/down/left/right. For this I would have to assign keystrokes for otherwise unused features, such as water rudder, tailhook, spoiler, maybe a door or two, haven't tried yet.

A still better idea would be to put the plane in autopilot mode and use the joystick, which already has the necessary axes. I know it can be done because I use this procedure for operating a tanker's boom.
 
If you use FSX and up, XMLTool's XMLKeys class is able to mask most, if not any, keyboard key (and joystick axis, but I haven't tried that yet). So basically, you can go to the gunner's position via camera and use the turret's power switch to enable keyboard controls for it and use, say, the arrow keys to control the turret.

It should also be possible to translate mouse cursor movements into turret or waist gun movement. Something like clicking the gun to activate mouse input and then have background gauge evaluate the X and Y cursor positions on screen and assign them to the gun's lateral and vertical rotation animations.
 
Speaking of turrets, I have five (!) of them to take care of, and I want each of them to be manually operated in horizontal as well as vertical sweeps. So far I have managed to implement this via a 2D gauge, which I am happy to share if there is any interest for it. I can mouse-click left to stepwise swivel left 36 degs, and click right to go the other way round, and use the mouse wheel to go up and down. So far so good.

What I really want, however, is to use three or four joystick buttons to go up/down/left/right. For this I would have to assign keystrokes for otherwise unused features, such as water rudder, tailhook, spoiler, maybe a door or two, haven't tried yet.

A still better idea would be to put the plane in autopilot mode and use the joystick, which already has the necessary axes. I know it can be done because I use this procedure for operating a tanker's boom.

Would it not be more realistic to have them each operating independently searching the skies using the "ambient" tag over 1000 KFs. And, maybe add control "power" switches to disable their movement.
My turret works well above 125 kias but I should add a "power" switch to shut it off for users who want it in "quiet" mode, like for ferry operations.
 
Don't really know what "over 1000 KF" stands for, what I am getting suggested on the net is "Kentucky Fried", which I gather isn't the intended meaning.

Personally I would find one or more (make that five) constantly moving or rotating turrets very distractive in sim and I would surely try to turn them off. That said, does anybody know how the gunners actually operated their gear?

As far as realism is concerned I believe it would be rather nice if the guns could be made to point either at AI or a multiplayer plane. Don't quite see how ambient could handle that...

Edit: Key Frames!! Should have known it. But it's not what I would use to get a reasonably slow movement.
 
Last edited by a moderator:
Edit: Key Frames!! Should have known it. But it's not what I would use to get a reasonably slow movement.
What, 56 seconds isn't slow enough?
1000 frames / 18fps = 55.555 seconds.
 
Code:
<!-- TURRET Animation based on in-flight for FSX -->
  
    <PartInfo>
    <Name>animate_turret</Name> 
        <Visibility>
            <Parameter>
                <Code>
                (A:AIRSPEED INDICATED, knots) 125 &gt;=
                </Code>
            </Parameter>
        </Visibility>
    </PartInfo>
  
    <PartInfo>
        <Name>noanimate_turret</Name>
        <Visibility>
            <Parameter>
                <Code>
                (A:AIRSPEED INDICATED, knots) 125 &lt;
                </Code>
            </Parameter>
        </Visibility>
    </PartInfo>

How can this code be altered to add an on/off toggle switch to control whether the animation should be activated above 125 knots? I would like the ability for the user to deactivate animations if desired.
 
You can either do it by adding a custom Lvar, say (L:turret_control, bool), and let the user toggle it on/off via a mouse area in the cockpit, or you can use an existing A: variable that can be toggled by hitting a key or a joystick button.

I often use the water rudder key for such purposes (normally Ctrl-W, but you'd have to check your key assignments). You need two steps to set it up:

1) add a pseudo water rudder to your aircraft.cfg under the [contact points] section:

point.nn= 5, 0.00, 0.00, 0.00, 2000.00, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.10, 0.10, 0, 0, 0 //Artificial water rudder

2) edit your two vis codes to read

(A:WATER RUDDER HANDLE POSITION, bool) 1 == (for the animate_turret version)

(A:WATER RUDDER HANDLE POSITION, bool) 0 == (for the noanimate version)

That should do it. I have tentatively left out the 125 kias restriction because I believe it's just as well if the turret can be operated in any condition?
 
Last edited by a moderator:
To illustrate another option, in my own project I can turn and tilt my turrets to aim at different targets as in the pic below. As mentioned before, for the time being turret movement is done via mouse clicks and presses.

wbCHA2tp.jpg


I have read that under the P3D regime mouse areas can also be defined in spot view. This would be nice to have for the turrets....So far I haven't got it to work because all my compiles are still based on the P3D 1.4 SDK.
 
Mouse control in P3Dv3/4 works simply by using the Attachpoint Tool to tag the object(s) with the MouseRect information. You can compile with any version of XtoMDL.exe from P3Dv1.4 up to v4.1...
 
Milton, the absolute simplest way is this:

Code:
<!-- TURRET Animation based on in-flight for FSX -->
 
    <PartInfo>
    <Name>animate_turret</Name>
        <Visibility>
            <Parameter>
                <Code>
                (A:AIRSPEED INDICATED, knots) 125 &gt;=
                (L:turret_control,bool) and
                </Code>
            </Parameter>
        </Visibility>
    </PartInfo>
 
    <PartInfo>
        <Name>noanimate_turret</Name>
        <Visibility>
            <Parameter>
                <Code>
                (A:AIRSPEED INDICATED, knots) 125 &lt;
                (L:turret_control,bool) ! and
                </Code>
            </Parameter>
        </Visibility>
    </PartInfo>
Simply add the manual control to the <Code> script with an "and" added! :teacher:
 
But Milton, if I understand him correctly, wants user_control to deactivate the ambient turret (post #11, above), whereas in this version it activates it.

Also there is a part missing, namely the gauge code where L:user_control is toggled off and on.

Finally, correct me if I am wrong, but if speed is less than 125, and the user toggles user_control ON then neither vis condition is true, and no turret will be visible at all.
 
But Milton, if I understand him correctly, wants user_control to deactivate the ambient turret (post #11, above), whereas in this version it activates it.

Also there is a part missing, namely the gauge code where L:user_control is toggled off and on.

Finally, correct me if I am wrong, but if speed is less than 125, and the user toggles user_control ON then neither vis condition is true, and no turret will be visible at all.
Good point! In that case this will fix that: use an "or" rather than an "and" in the script evaluation.
Code:
<Code>
        (A:AIRSPEED INDICATED, knots) 125 &lt;
        (L:turret_control,bool) ! or
</Code>
I didn't provide the script to control the L:variable since Milton surely knows how to do that.
 
Mouse control in P3Dv3/4 works simply by using the Attachpoint Tool to tag the object(s) with the MouseRect information. You can compile with any version of XtoMDL.exe from P3Dv1.4 up to v4.1...
Thanks for this hint. I now managed to get a mouse rect to work in spot view using a V1.4 compile. Pretty neat.

And for Milton's turret project this would mean that the user_control variable could also be set by clicking on the turret in exterior view ... at least in P3D.
 
Last edited by a moderator:
Good point! In that case this will fix that: use an "or" rather than an "and" in the script evaluation.
Code:
<Code>
        (A:AIRSPEED INDICATED, knots) 125 &lt;
        (L:turret_control,bool) ! or
</Code>
I didn't provide the script to control the L:variable since Milton surely knows how to do that.

Thanks for all the conversation on this topic. I am certain it will help more than just me.

LOL Bill; surely if I did, I would not be asking questions about such basic code. :-) But, I am slowly making progress in understanding xml.
 
Oh, in that case here is the mouse script:
Code:
<PartInfo>
  <Name>TurretAnimation</Name>
  <MouseRect>
    <Cursor>Hand</Cursor>
    <CallbackCode>
      (L:turret_control,bool) ! (>L:turret_control,bool)
    </CallbackCode>
  </MouseRect>
</PartInfo>
 
Back
Top