Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Animate Shadow Caster 2D Shape

Discussion in '2D Experimental Preview' started by danio_quero, Jan 21, 2022.

  1. danio_quero

    danio_quero

    Joined:
    Jul 15, 2019
    Posts:
    1
    Hi, I'm working on a 2D game and using 2d lights and shadow caster. It seemed so easy at first so I tried to push it a little bit.

    I have an animated sprite, so I thought I could just click on the record button and tailor the shadow caster shape around the sprite silhouette, frame by frame. An exhausting job but it paid off when I did it with a collider.



    It seems that, no matter what, the shape remains still during the animation, namely in its last setup.
    The question is: is there a way to "animate" the shape?

    Thanks
     
  2. Lightspeed15

    Lightspeed15

    Joined:
    Jan 29, 2021
    Posts:
    2
    I have the exact same problem. I wonder if they just haven't added that feature yet?
     
  3. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    Hey @danio_quero and @Lightspeed15 thanks for sharing your use cases!

    Unfortunately, it isn't possible to animate the Shadow Caster 2D control points currently as it isn't quite supported yet.

    However, the team is currently pushing for shadows interoperability with the rest of our 2D features; animation being one of them. So ideally, once this is ready, throwing a shadow caster 2D onto an animated character (be it a flipbook or a bone-based character like yours) will have the shadow caster updated accordingly as well.

    Once we do have any newer updates, we'll be sure to post them on our 2D Public Roadmap.

    In the meantime, feel free to leave any more feedback here. They help us a lot.

    Happy creating! :)
     
    FNN_1 and NotaNaN like this.
  4. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    As was stated earlier, this feature is in the process of being implemented. However, the workaround for this is that you can add shadow casters to the bones. When the bones animate the shadow casters will animate as well. Likely you will want to use a composite shadow caster to avoid having the body parts cast shadows on themselves.
     
    FNN_1 and Xiangting_Su like this.
  5. FNN_1

    FNN_1

    Joined:
    Apr 1, 2017
    Posts:
    2
    Hello team! thanks for the feedback, but i tried adding shadow caster and composite shadow caster to the bones, but it's not working. When he performs the movement animations he does not generate any shadows. The animations were already done before adding the shadow casters, could that be affecting it? Any other workaround that you know to be able to generate shadows to the bones of the characters in 2d when moving? Thank you very much!!
     
  6. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    This should work. I'll post some screenshots next week if you can't get it sorted out by then. If those don't help, it would be great if you could file a bug report. But I think they should help.
     
  7. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    @FNN_1 Did you get this sorted out?
     
  8. CoraBlue

    CoraBlue

    Joined:
    Nov 16, 2017
    Posts:
    60
    I know you guys are hard at work, and you've heard from me about this before (I really would love sprite pixel data shadows and tilemap collision composite shadows) but I just want to take a second to cheerlead. The work you're doing has a profound impact on the quality of 2D Unity games out of the box. Here's a quick showcase from my game of what you make possible.



    I'm not sure if this is the thread to do it, but the only QoL feature I'd like that hasn't been requested is normal distance per layer on lights. It's nice to have that rim lighting on foreground objects while still illuminating the background. The workaround is two lights. Totally fine, but sometimes an editor headache.
     
    Xiangting_Su likes this.
  9. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    253
    Thank you for sharing! This looks amazing! I also really love what you did with the ice reflection. :D

    Well-noted on these 3 requests:
    • Sprite pixel data shadows
    • Tilemap collision composite shadows
    • Normal distance per layer on lights
    Let me bring them back to the team so that we can see what we can do.
     
    AzureMasters likes this.
  10. hassanreskin

    hassanreskin

    Joined:
    Mar 7, 2018
    Posts:
    1
    I have solution:
    the solution is : instead of creating a one shadowcaster and editing shape, you can create for every piece of character its one shadowcaster and exclude shadow for sorting layer to not effect shadow for character exept BG and other object you want to be effected by shadow