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

[ISSUE] Lightmapping a 2d frame by frame animated character

Discussion in '2D' started by jscarbrough, May 30, 2018.

  1. jscarbrough

    jscarbrough

    Joined:
    Sep 7, 2016
    Posts:
    21
    So we're building a game with animated characters, obviously, and the only way I can think to make the lighting system interact with the characters is to create a material for every single frame of the animation with a normal map material on one side and the sprite on the other, the same way you would cause a static sprite to interact with the lighting, which we've done with lots of stuff.

    We created ONE material for each of two different moving monsters and dropped it in the material slot of the monster in the sprite renderer. We did this also for a monster spawner that's animated as well. Each material only used a single frame and a single light map.

    For some reason it worked on the spawner and that spawner is now animated and interacts with light, so we thought we might have found a faster way to make 2d animated characters interact with the lighting systems. The monsters are black and do not. Clearly we were wrong, but I'm not sure how the first one worked.

    Does anyone have a work around for lightmapping animated sprites so we're not spending weeks creating light maps for every single frame? Any help would be greatly appreciated.

    Thank you!
     
    TheAngryTophat likes this.
  2. cateia97

    cateia97

    Joined:
    May 28, 2016
    Posts:
    1
    I'm watching this to see if there are any better solutions, but I've stumbled upon making this work much like you have. It looks fine except the animation gets kind of "strobey" in strong light (it looks great in ambient light), though that may be more of me setting up the animation in a truncated way for testing while our artist makes the final assets.

    I've managed to get all of my sprites to light, though. I've set up separate materials for each, even if they're the same outline/shape. I did that because a core mechanic of the game relies on color changes and light reactivity, so I wanted to avoid conflict. Maybe try setting separate materials for each variety of monster? It creates more of an asset load, but maybe Unity's freaking out over the common material. (Just spitballing, I'm by no means an expert.)

    [Edited to add that I figured out my strobing issue; I forgot to set the lightmap to use grayscale and take the bumpiness down to 0.]
     
    Last edited: Jul 28, 2018
    TheAngryTophat likes this.
  3. TheAngryTophat

    TheAngryTophat

    Joined:
    Apr 13, 2018
    Posts:
    6
    We'll definitely have to give that a try.