Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question 2D Lighting in 2.5d game

Discussion in '2D' started by ChuckieGreen, Oct 21, 2023.

  1. ChuckieGreen

    ChuckieGreen

    Joined:
    Sep 18, 2017
    Posts:
    354
    I am making a 2.5d game and trying to get the lighting working correctly. Some enemies have a light attached so when they approach a building, the light should effect the building, however because its 2.5d the light should only effect certain parts of the building (like the parts near the ground). The image below is a basic layout of one of the buildings, as you can see the light is effecting the top and sides of the building, which wouldnt make any sense since the enemy(light) is meant to be on the ground behind the building. I know i can use shadow masks, to mask off the tops of the building so the light wont effect that, but this wouldnt work with the sides because in certain areas the light should leech onto the buildings. I am also looking into trying to mask certain areas off using avo? in Blender, but dont know a lot about that. Wondering if anyone else has any ideas that I could try out, to get it to work the way I am wanting. Thanks



    upload_2023-10-21_15-34-55.png
     
  2. venediklee

    venediklee

    Joined:
    Jul 24, 2017
    Posts:
    150
    You can get that effect using normal maps on your sprites, enabling the normal maps in your 2d lights and adjusting the height parameter(under normal maps section) of your 2d lights.

    That being said, it looks like you are at the beginning of your 2.5d game journey. I would highly suggest you just do a 3d game with an isometric camera instead. Almost everything will be easier, almost everything will have better tools and tutorials.
     
  3. ChuckieGreen

    ChuckieGreen

    Joined:
    Sep 18, 2017
    Posts:
    354
    Thanks a lot, I will give the normal map idea a try. I know the game doesnt look like much from the image, but about 85% of the code for the game is in place, its just the assets etc thats been left till the end, so cant really switch to 3d now. If I am doing a 2.5d game again though I will go with 3D.
     
    venediklee likes this.
  4. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,325
    A very simple act of fakery is to adjust your art so the tops of your buildings are very dark. Right now you've got the shadow in the down-right direction. So move it to the top, then put a gradient on the sides of the building so they're only partly affected by lights behind the building.

    dd - Copy.png

    It won't solve the problem only cover it up somewhat. But if lights are on the floor, then relatively darker roofs makes sense.. so long as it's not too sunny out!
     
  5. sildeflask

    sildeflask

    Joined:
    Aug 16, 2023
    Posts:
    181
    2d lights cant be sorted

    that is the root of the problem