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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

2D directional shadows.

Discussion in '2D' started by Lorel_Adme, Mar 9, 2015.

  1. Lorel_Adme

    Lorel_Adme

    Joined:
    Aug 8, 2014
    Posts:
    3
    There is no info on how to make directional 2d shadows. Help.
     
  2. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Just use a sprite as the shadow, it's not really a build in feature as 2d stuff generally isn't lit.
     
  3. Lorel_Adme

    Lorel_Adme

    Joined:
    Aug 8, 2014
    Posts:
    3
    I mean something more like this,
     
  4. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    You'd have to do it yourself, or do it in 3d and use the orth view setting on the camera.
     
  5. darksire

    darksire

    Joined:
    Dec 16, 2013
    Posts:
    10
    Use this shader on your sprite material it going to cast shadow for u ^^.
    On the Base (RBG) select your sprite.
    dont forget to choose the debug mode to change the material setting to be able casting shadow .

    Castshadow.jpg
     

    Attached Files:

  6. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
  7. darksire

    darksire

    Joined:
    Dec 16, 2013
    Posts:
    10
  8. sleekdigital

    sleekdigital

    Joined:
    May 31, 2012
    Posts:
    133
    TheValar likes this.
  9. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    That depends. It's based on the collider you have on your object so if the collider is animating along with the sprite then I don't see why not
     
  10. darksire

    darksire

    Joined:
    Dec 16, 2013
    Posts:
    10
    usually 2d character dont have collider like their shapes they got a box or circle colliders so the shadow will not be like the character.
    With my shader u will get the shadow of the character and its moving like the animation of the character.
    So the shadow based on the collider its not a good solution for characters
     
    Last edited: Mar 9, 2015
    theANMATOR2b likes this.
  11. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    760
    I guess it all depends on your specific needs :) definitely seems like a cool shader!
     
    darksire likes this.
  12. Lorel_Adme

    Lorel_Adme

    Joined:
    Aug 8, 2014
    Posts:
    3
  13. sleekdigital

    sleekdigital

    Joined:
    May 31, 2012
    Posts:
    133
    It has an option to limit the angle. Use one of those large enough starting somewhere off screen and you essentially have directional. I haven't tried this but it seems like it might work, depending on the details of your needs.
     
  14. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    924
    Sorry for necroposting, did you find any alternative?

    I can't seem to find a working solution for 2D and Unity 2018 :-/

    Looking for advices.