Forum rules - please read before posting.

sorting layers and global lighting

hi,

[unity 6 6000.0.32f1];
[adventure creator 1.83.0];

I have several layers for sorting:

  • layout_ground is used to display the tilemap. This layer is affected by global illumination with minimal brightness.
  • layout is used to display the same tilemap as layout_ground, but with a brightness of 0.5.
  • layoutShadowArea is used for displaying the tilemap with slightly less brightness than layout.
  • ENV (pro, player, NPC) is used to show sprites of objects and characters. This layer has the same lighting as layout.
  • ENV_Shadow Area (pro, player, NPC) displays the shadows of objects and characters using the same lighting as layoutShadowArea.
  • Layout_Top is used to display a different version of the tilemap that is affected by the same lighting as Layout_Ground.

I have a global variable called "TimeOfDay" with the values "day", "day_rain", "evening", and "night". When a scene starts, the current value of this variable is passed to a sprite animator called "view outside the window" in order to change the texture. The value is also passed to a global light animator in order to set the lighting based on the time of day.
To create a shadow effect in one part of the room, I have divided the room into different layers. However, there is a problem with sorting the character relative to the objects in the darkened area, as the character and the objects are on separate layers.

In order to solve this issue, I added a trigger at the entrance to the dark area that changes the sorting layer of the character's prefab to "ENV_ShadowArea" (props, player, NPC).

Is there a more efficient way to achieve this effect?

Comments

  • Are these Sorting Layers, or regular GameObject layers?

    This sounds like more of a general Unity question, but URP's 2D Renderer has good lighting options - you could try making a light that affects characters but only in the bright areas of the room.

  • Are these Sorting Layers, or regular GameObject layers?

    yes;

    you could try making a light that affects characters but only in the bright areas of the room.

    in fact, that's what I did, I have different global lights installed on different sorting layers; the question is, is this the right approach or not?

  • Sound like it to me.

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.