Announcement

Collapse
No announcement yet.

BP_Sky_Sphere not respecting Refresh Material and Update Sun Direction for day/night cycle

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    BP_Sky_Sphere not respecting Refresh Material and Update Sun Direction for day/night cycle

    I feel like I'm going crazy here. I have implemented a day/night cycle with the following setup:

    - Added directional light. Set mobility to "Movable"
    - Added BP_Sky_Sphere. Set Directional Light Actor to be the previously created directional light

    - In level blueprint, used Event Tick to add to the directional light's yaw, then set BP_SkySphere to Refresh Material and called Update Sun Direction

    I confirmed my directional light is rotating but the sun position never does. I feel like I'm missing something very obvious and it's incredibly frustrating. Can anyone see anything wrong with this setup?

    Also, in the level blueprint, "TimeScale" is 30.

    If I manually rotate the directional light and hit "Refresh Material" on the sky sphere, it updates fine. I have no idea why it doesn't work in the blueprint.

    I seem to be having issues linking to my screenshot, here it is: https://i.imgur.com/Pou8WmW.png
    Last edited by Chumble; 03-13-2018, 12:53 PM.

    #2
    Without digging into the actual blueprint for the skysphere, I'm guessing that the updating is taking place in the construction script. If it is, then this doesn't get run in game. You'd need to recreate the function inside of the regular portion of the blueprint and run it there. I don't have the editor open right now, but I'll double check in a bit and see if this is the case.

    Comment


      #3
      After trying it out, I guess there is a function built in to update the sky variables. You have to get a reference to the sky and call the function from within. If you are doing this from another blueprint that isn't the level BP, then you will need to get all actors of class for the BP_Sky_Sphere class, get the 0(first) reference, cast to type BP_Sky_Sphere and then from the blue pin on that, you'd then be able to execute the update function.

      Quick test rig in the level blueprint:

      Click image for larger version

Name:	Untitled.jpg
Views:	330
Size:	215.0 KB
ID:	1442893

      Timeline graph:

      Click image for larger version

Name:	Untitled2.jpg
Views:	327
Size:	50.9 KB
ID:	1442894


      Click image for larger version

Name:	Untitled3.jpg
Views:	330
Size:	33.0 KB
ID:	1442896

      Click image for larger version

Name:	Untitled4.jpg
Views:	329
Size:	30.8 KB
ID:	1442898

      Click image for larger version

Name:	Untitled5.jpg
Views:	330
Size:	38.9 KB
ID:	1442897
      Attached Files

      Comment


        #4
        Your setup is extremely similar to what I have in place already (see screenshot in first post). Only difference is you're not flagging the sky sphere to reset the material and I'm using tick instead of a timeline. There must be some other difference here I'm not accounting for. What version are you using? I'm on 4.18.3. Would you be able to send me your project so I can compare each piece side by side?

        Comment


          #5
          Oh I didn't see that you had a screenshot of your material graph. Yeah, it's a pretty similar setup. I think I see what's going on with yours though: You don't need the refresh material node because that executes code inside of the construction script and that's not available in game. Plus, that's already in the update function, so you'd be running it twice. Remove that node and only execute the update function. Make sure you're testing by going in game or simulating. The regular non-game viewport isn't going to reflect those changes usually due to having to wiggle the skybox around or click the update button. In my example, the sky's material is definitely updating just fine and goes from a dark and starry night time, to an orangish evening time, to a bright noon.

          I can't send the project because it's massive but I can tell you that it's the default 3rd person scene and that the code shown in the level blueprint is pretty much all that's added. The timeline node is going from (0,0) to (2.5,-89) to (7.5,89) to (0,0) and is set to loop with a duration of 10s.


          EDIT: Even more obvious: You're using local rotation and therefore, the actual actor isn't rotating at all. Change it to AddActorWorldRotation.
          Last edited by IronicParadox; 03-13-2018, 02:53 PM.

          Comment


            #6
            I found the issue. It's really dumb. I was updating the roll, not the pitch.

            Sigh.

            Changed that and nothing else and now it works perfectly. Thanks for the time and effort you put into helping.

            Comment

            Working...
            X