• 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 Determining day and night

Messages
124
Country
unitedstates
Has anyone found a way to determine if it is day or night in MSFS? I have found how to do it with visual effects but would like to use the day/night cycle to start or stop animations.
 
Messages
124
Country
unitedstates
For those interested, there is a system variable not documented in the SDK for time of day. Digging through ModelBehavior XML, I found:

TIME OF DAY enum : 1 = Day ; 2 = Dusk/Dawn ; 3 = Night

I have not gotten it to work, yet (I'm still figuring out how to use postfix, but it does look like what I was looking for.
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
Code:
(E:Time of Day,enum) 3 == if{ L:Night,bool) }
(E:Time of Day,enum) 1 == if{ L:Day,bool) }
There are many other alternatives if you wish to include dusk and dawn. The simplest is to consider not-night:
XML:
(E:Time of Day,enum) 3 != if{ L:Not_Night,bool) }
Once done, simply read the L:vars status to perform your animation/visibility, or not...
 
Messages
75
Country
germany
This is the code, I use for my glider-winch and start area:
The 3d models and animations appear only between 10 a.m. and 6 p.m. But if, for example, dusk starts before 6 pm, or it rains, the 3d models and animations are not to be seen.
And you can show different nodes (nodenames) with different behaviours in one glTF file.

XML:
  <Code>(E:LOCAL TIME, Seconds) 36000 &gt;= (E:LOCAL TIME, Seconds) 64800 &lt;= and (A:AMBIENT PRECIP STATE, mask) 3.0 &lt; and (E:Time of Day, enum) 2 &lt; and if{ 1 } els{ 0 } </Code>
.
 
Messages
122
Country
russia
Hey guys!
Is it possible to make the animation started at a certain time of day? Exactly so that the object would start moving, not visibility, to appear at that time. For example at sunset would be played once, and at dawn, too, but in the opposite direction (well, or the keys to divide).
I do not understand what parameters to use for this. Most likely it is not "sim" but "standard"? Since this is not an airplane, but an object on the ground. Autoplay is also not needed, should I use random?
Should we use partinfo as before or by modern standards should it all be in the BlendTreeState part with the Value parameter? Already tried a hundred options, but never got it to work.
Any ideas would be appreciated. Thank you.
 

connomar

Resource contributor
Messages
263
Country
us-minnesota
These snippets of information are great, but I am struggling to make sense of them. Please could one of you post a whole file so I can see how you are using the variables you appear to be creating?

<?xml version="1.0" encoding="utf-8"?>
<ModelInfo guid="{2fefa58c-ba4d-4063-8e2d-449c1c33346a}" version="1.1">
<LODS>
<LOD minSize="0" ModelFile="KDYT_Beacon.gltf"/>
</LODS>

<Code (E:Time of Day,enum) 1 == if{ L:Not_Day,bool) } /Code>

<Animation name="Beacon" guid="12f9185b-10ca-48ac-b45c-da1505b947ba" type="Standard" typeParam="Autoplay"/>

</ModelInfo>

------------------------------------------------------------------------------------------------
I am trying to make the Animation only work at night, as it is an Airport Beacon which I have modelled with a rotating top.

Any help would be gratefully received.

Martin
 
Messages
766
Country
italy
To obtain what you want you need two separate mesh in your glTF (one animated and one still)
Than, with a Simboject, you can control the visibility based upon time of the day

Some tutorial to get you started





Inviato dal mio Mi 9 Lite utilizzando Tapatalk
 

connomar

Resource contributor
Messages
263
Country
us-minnesota
To obtain what you want you need two separate mesh in your glTF (one animated and one still)
Than, with a Simboject, you can control the visibility based upon time of the day

Some tutorial to get you started





Inviato dal mio Mi 9 Lite utilizzando Tapatalk
Thank you so much, I will have fun watching them.
 

connomar

Resource contributor
Messages
263
Country
us-minnesota
Hi Mamu, I think I have followed your tutorial fully, yet I cannot get any activity to occur based on the parameters. I decided to cut out the animation bit to simplify things, and created a really simple Blender file which has two meshes, one says Day the other NotDay. They are text that has been converted to a mesh.

DaySign Check.jpg

<?xml version="1.0" encoding="utf-8"?>
<ModelInfo guid="{54cb674c-5333-444c-95f5-114a68edca85}" version="1.1">
<LODS>
<LOD minSize="0" ModelFile="DaySign.gltf" />
</LODS>
<Behaviors>
<Component ID="a" Node="Day">
<Visability>
<Parameter>
<Code>(E:Time of Day,enum) 1 == if{1} els{0} </Code>
</Parameter>
</Visability>
</Component>
<Component ID="b" Node="NotDay">
<Visability>
<Parameter>
<Code>(A:Time of Day,enum) 1 != if{1} els {0} </Code>
</Parameter>
</Visability>
</Component>
</Behaviors>
</ModelInfo>

The result never changes, both Day and NotDay meshes display. I have tried replacing the Code Statement with {1} in case this is an evaluation issue, but the meshes stay turned on. I am using the Asobo Blender Exporter and wonder if this is failing doing something strange. I have spent all day on this and got nowhere. Can you see any errors?
 
Messages
766
Country
italy
There is a spelling error in the code,

Visability

Must be

Visibility


I have included a working Simboject sample from my LIDT scenery so you can compare yours (basically showing a lamp post to cover the Asobo orbs during the night when it was not yet possible to exclude them!)

Inviato dal mio Mi 9 Lite utilizzando Tapatalk
9c1c36154d8c49de5ef4cf859c3faa7a.jpg

View attachment 82866
View attachment 82867
 

Attachments

  • SimObjects.zip
    131.1 KB · Views: 83
Last edited:

connomar

Resource contributor
Messages
263
Country
us-minnesota
Thank you so much, and English is my FIRST and only language. I'm too used to having Visual Studio correct me.
Martin
 
Messages
766
Country
italy
Thank you so much, and English is my FIRST and only language. I'm too used to having Visual Studio correct me.
Martin
I use mostly notepad for this small snippets,
(And if you have watched the tutorial I'm making errors too!)
but sometimes I use visual studio code for .XML, there is a validation file in the SDK docs called bglcomp.xsd you can use 🤓
 

connomar

Resource contributor
Messages
263
Country
us-minnesota
I use mostly notepad for this small snippets,
(And if you have watched the tutorial I'm making errors too!)
but sometimes I use visual studio code for .XML, there is a validation file in the SDK docs called bglcomp.xsd you can use 🤓
I hadn't thought of using the VS Editor like that. Great idea! The correction to Visibility fixed the test file immediately. Now I have to get the beacon working correctly. I assume that this method only works with meshes, as opposed to Collections? My beacon has a light-sun in front of each lens that must spin with the beacon. I think this might turn out to be the next major challenge.
 
Messages
766
Country
italy
Actually it is "node" based, and by node I mean the gltf node
So, if you parent your light to your mesh it is likely to work (never tried that but should be)
Also, your mesh, being a beacon, thus being rotated, should be parented to an empty because of...performance? Dunno, Asobo parent everything is moving to emptys
So you will end up with
EmptyDay
-- meshDay
---- lightDay

And your Component node will be "EmptyDay" or such


Inviato dal mio Mi 9 Lite utilizzando Tapatalk
 

connomar

Resource contributor
Messages
263
Country
us-minnesota
Actually it is "node" based, and by node I mean the gltf node
So, if you parent your light to your mesh it is likely to work (never tried that but should be)
Also, your mesh, being a beacon, thus being rotated, should be parented to an empty because of...performance? Dunno, Asobo parent everything is moving to emptys
So you will end up with
EmptyDay
-- meshDay
---- lightDay

And your Component node will be "EmptyDay" or such


Inviato dal mio Mi 9 Lite utilizzando Tapatalk
Great! That will add some more to play with. Right now, the animated beacon disappears at dusk. so a way to go. - Looking for spelling mistakes lol!
After a lot of messing around, it seems that nothing I do, including removing the entire Behavior section, will make the model animate when it is a SimObject. Make the same model a standard model in ModelLib and it spins happily. I tried the Behavior code in the non Simobject setup, but that achieved nothing. Sad, because that would be so much easier. Maybe it won't let me animate without an empty parent.

I only have 3 hangars to model and a few parking spaces to add and this project is complete, so it may have to stay rotating in the day.
Thanks for all your help, it is greatly appreciated.

Martin
 
Last edited:
Messages
766
Country
italy
For the day option use < 3 if {1} els {0}
For the night option == 3 if {1} els {0}
32aa4ee932354bfe5ad7fa1720853857.jpg


Inviato dal mio Mi 9 Lite utilizzando Tapatalk
 
Messages
4
Country
australia
Another issue with the code

<Code> (A:TIME OF DAY,enum) 1 != if{ 1 } els{ 0 }</Code>
A: is Aircraft variable no good

should be

<Code> (E:TIME OF DAY,enum) 1 != if{ 1 } els{ 0 }</Code>
E: is Environment variable

ColinJ
 

connomar

Resource contributor
Messages
263
Country
us-minnesota
Another issue with the code

<Code> (A:TIME OF DAY,enum) 1 != if{ 1 } els{ 0 }</Code>
A: is Aircraft variable no good

should be

<Code> (E:TIME OF DAY,enum) 1 != if{ 1 } els{ 0 }</Code>
E: is Environment variable

ColinJ
Thanks Colin, I must have corrected that later and forgotten all about it.
 
Messages
148
Country
ca-ontario
I tried to have a model only showing up at night using this method so I added the ModelBehaviors tag at the end of the model's XML file and rebuilt, but it still shows up 24/7:

Code:
<?xml version="1.0" encoding="utf-8"?>
<ModelInfo guid="{eac09140-d30d-42fb-81e4-5a6a4cd8c2d1}" version="1.1">
    <LODS>
        <LOD minSize="0" ModelFile="Secret.gltf"/>
    </LODS>
</ModelInfo>
<ModelBehaviors>
    <Component ID="secret" Node="Night">
        <Visibility>
          <Parameter>
            <Code> (E:TIME OF DAY, enum) 3 == if{ 1 } els{ 0 } </Code>
          </Parameter>
        </Visibility>
      </Component>
</ModelBehaviors>

Am I missing something? Should this behavior be working in the SDK editor too when you change time of day, or only when you add this package to your Community folder and load the game with it as a user? Should the model disappear as soon as you advance the time to daytime and re-appear instantly when you change to night?

What I would really like to do is have a whole group of object appear/disappear, including this model as well as some MSFS generic models around it. Is there a way I can do that? Can you insert this behavior in the project's XML file and make it act on several objects?

Edit: I tried using a Behaviors tag instead of ModelBehaviors and it made no difference. I added another instance of the object after I had modified the object XML file and built the project again, all instances of it still show up 24/7.

Edit 2: OK I got it to work, what I did wrong was that the Node was specifying a collection in my gltf file instead of an object (the model was composted of several objects). In Blended I joined all my objects, gave it a name and refer to it in Node=, now it works. I still don't know how to read the current state of the E:TIME OF DAY variable in the Simvars utility, I tried manually putting in the name but I can't get it to return a value. I don't really need it at this time though, I can tell it's working.
 
Last edited:
Top