Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Alternate between 2 backgrounds on a timer


I want to make the light in my 2d background painting fluctuate. I'm planning to do this by changing on a timer to a 2nd variation painting of my background, possibly with a transition.

I don't know how to do this, but my guess would be to write a script to check a time ellapsed. Any help with that would be great. Then call that script to be checked for time elapsed, then transistion to alternative bg sprite.

I'm a total n00b so don't know how to set that up and where to set it up within alll the intricate menus of AC. Would much appreciate a helping hand at getting started with this.


  • edited February 12

    Ok, Sprite fader combined with OnStart ActionList is working well for this effect. See image.

    However when working it has disabled my hotspots and cursors. I believe this is because it is in OnStart. I tried making an action list for OnLoad with the same setup, the interaction is back but no fading happens. Any ideas?

  • An ActionList will prevent regular player movement and interactivity if its When running field is set to its default value, Block Gameplay. Change this to Run In Background in its Inspector to prevent this.

    See the Manual's "Background logic" chapter for more.

    It's also not necessary to rely on a looping ActionList like this to achieve this effect, since animation can give you such control. Attach an Animator component to your sprite and create a new looping Animation clip inside it to change it's colour over time. This is all done using Unity's Animator system, separate from AC, and you can learn more about it here.

    Should you need to control your Animator's playback at runtime (e.g. start/stop the animation) you can do so using AC's Object: Animate Action. The animation will play by default without this, however.

  • That is great, for some reason I never figured that an action list had Inpector options.

    I'll take a look at the animation stuff which I'm sure I'll need at some point.

    Is using an animation more effecient in any way in this situation?

  • It is, and by attaching a Remember Animator component to it, you can also store its state in save games.

    A basic knowledge of Unity's key systems, such as animation, is recommended before going too far into AC. The 2D tutorial video, however, is geared towards totally fresh users.

  • Thank you for the links Chris, I can now bring animations into AC.

    I do believe in this instance though that using sprite fading is more cpu efficent for the player than animation. To get an effect as smooth using animation for a transition between the two key images, I'd need about (100) 1920x1080 pngs. That's compared to using just two and Unitys' inbuilt algorithm to go between.

    Granted for most animation one would need more than just a fade.

  • You don't need a separate sprite for each frame - you can animate the sprite color's alpha channel.

  • Gotcha! I'm slowly getting a more pieces of unity knowledge. Thanks for your help.

  • I've been playing around with this and please stop me if this is getting too off topic from AC. However I appriciate any direction pointing anyone can give.

    I've trying to find a way to get the background of multiple rooms to darken and lighten on a timer, and I'd like to find the most efficient way of doing that.

    I've currently got my 2d game setup with all rooms in one scene, like in the FirstPerson2dDemo. I am using a Cinemachine Brain on my main camera and switching to CM Virtual cameras depending on which room is needed to display.

    I am looking for a way to apply this lighten/darken effect to a group of rooms, which all happen to be in the same "place" in the game world. It makes sense to me that I should apply this not to each Virtual Camera but perhaps to a Parent for the group which will pass down this effect to all its children.

    I figure I'll have to get involved with Timelines and Post Processing Stack applied to the Parent. But my question is; the idea listed above, is that the right way of going about this problem and what kind of object should the Parent be? a virtual camera? an empty game object? Do I need the parent to be a CM brain itself?

    Any guidence on this or just how to think about or approach this would be fantastic.


  • This is indeed going off-topic, since you're now discussing Cinemachine and Post Processing Stack - two Unity assets that aren't related to AC.

    I'm not clear why you're using CM Virtual cameras if your game is in 2D, since I'd imagine they'd be static.

    Regardless, if you're trying to achieve the effect with PostProcessing - and not by changing the backgrounds themselves - such processing will only affect your main camera. The location / hierarchy of your virtual cameras should be irrelevant, I'd imagine. You should take this question to the Unity forums, however.

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.
Do NOT follow this link or you will be banned from the site!