How do I (Time of Day)

  • Hi all, I have a Lighting layout which works based on a timer. However I would like to scrap the timer and replace it with something a bit more too advanced for my small head.

    I have attached an image of a sun and the planet that the player will be on.

    I am trying to make it so that when the planet is going behind the sun that the layout lighting will have its opacity changed based on this and vice versa for infront. Of course the Lighting layer opacity shouldn't at a click of a finger become night, I'd like a transition effect.

    Does anyone know the best way of achieving this please ?

    The Sun is a stationary sprite with a rotate behaviour (It has no path of direction) The planet moves based on the Sine horizontal movement method.

    The way I have the planet appearing in front and behind the sun is by using invisible objects. If the planet overlaps either of them, depending on what they are, the planet is either set at the back of the layer or infront.

    Here are some images.

    imgur.com/a/AQfUPs8

    imgur.com/a/tdSHPMS

    Thank you, I hope you can help.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can use distance() expression.

    Something like this:

    Every 0.5s -> NightBlock set opacity to lerp(80, 0, distance(planet.x, planet.y, sun.x, sun.y)/200)

    If the planet is more than 200px away from the sun, opacity will be 0.

    As the planet moves closer, opacity will increase up to 80.

  • What would we all do without your infinite wisdom. Thank you.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)