Forum rules - please read before posting.

day-night cycle, scene to scene

Hello! My game is lit in real time, with a day-night cycle. How can I transport my sun from scene to scene? I have tried putting a ConstantID on it but it doesn't seem to work.

Comments

  • How do you keep track of time and how do you move the sun within a scene? My game is 2d and I don't have a sun, but I do have a day/night cycle and a very strict NPC schedule – so I have a script to interpolate the NPC position in the scene at any given time, and I run an AC actionslist on start/load of every scene to teleport the NPC to the desired location. Maybe that's something you could do for the sun?
  • mmm interesting. I'm going to try something like that. I have bought an asset to do it, in the asset store there are several, for 3d and for 2d.

    Your game must have a lot of narrative depth, it sounds good

  • Ah, that sounds cool. It's not hard to get AC to "talk" to other assets, but the specific solution in your case will really depend on how the other asset works. For example, if it keeps track of time and positions the sun according to the time, it could be just a matter of writing a script to link an AC variable to it, and then writing a custom action to copy that number over when you change scenes.
  • So can I move the same sun from scene to scene? Or do I create a sun in each scene, and every time I change the scene I pass the values ​​to the sun?

  • sorry but my bad english :#

  • Yeah, the way I would usually do it would be to have a sun in each scene and use AC to help me set it up, but I think you can also use Unity's DontDestroyOnLoad function to have a single persistent sun. The latter solution is unrelated to AC though, so you'd probably have better luck searching the Unity forums and Answers pages for more info.
  • edited February 2021

    AC's ConstantID component does not affect an object's persistence in the scene - it merely allows it to be referenced by the save system and asset files.

    DontDestroyOnLoad will make it persistent, but - as Rairun says - it's unrelated to AC.

    A separate asset should be able to handle things independently from AC, but you may need to write a custom Remember script to have its state stored in save games. For details, see this tutorial.

  • thanks! i will investigate

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.