Search Unity

Can you just animate a 4K map as a sprite without issues (2D)? Or is that too much of a memory load?

Discussion in '2D' started by Oir_the_tentacular, Dec 6, 2021.

  1. Oir_the_tentacular

    Oir_the_tentacular

    Joined:
    Nov 26, 2021
    Posts:
    76
    Hello all!

    I'd like for my 2D game to have an animated map. The environment is twitchy and moving all the time so I'd really like to make this happen. My maps will be 4 - 8k pixels wide/tall. The animations would be very simple. Maybe about 4 different keyframes looping at a low framerate. The only technique I'm aware of for making this happen would be to have the map as a sprite and use the animator just as I would for a player/enemy animation.

    My game runs at 1920x1080p and is not pixel graphics. I.e. heavy compression will start to make the map look pretty awful so I'd like to avoid it or just have it used in a minor fashion. I'm also not using any shaders/lighting system as I am just manually painting those in to the sprites themselves.

    Questions I have:

    1. Would this be realistic in any scenario? Or is working with maps this large just never going to load for anyone besides high end gaming pc's? I know this depends on other things taking up resources but for the sake of this question, please assume that the animated maps are taking up the bulk of the resources (which I suspect is quite close to reality in this case)

    2. If I were to do this, with such large sprites, would it still be optimal to stick all of them into a spritesheet atlas which would be like 20,000 pixels wide/tall? Or would it be more efficient to load them as separate .pngs?

    3. Is simply setting them up in Sprite Renderer and animating them like I would a player/enemy optimal? Is there anything I can do to squeeze a bit more performance out? Would this be an instance where loading chunks of the map might be best practice? Or is that not necessary?

    Thank you for your time!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    Every scenario is different. A $49 cheapo Android phone might not have hardly any RAM. Top of the line gaming PC might do just fine. Or it might not. Everything has a limit.

    No need to assume anything, do your own tests with the profiler. Get numbers, reason about ballpark figures if you're 10x over or 10x under, or right at the limit.

    I'm told all the kool kids are using things like Spine and Anima2D to do their 2D animations. You basically chop the sprite into reference sub-parts, put them together much like regular 3D geometry, rig them and animate the bones.
     
  3. Oir_the_tentacular

    Oir_the_tentacular

    Joined:
    Nov 26, 2021
    Posts:
    76
    Thanks for the response, Kurt!

    I was just estimating because I didn't want to animate my entire map and then test it out to see that it was completely un-runnable and all my efforts would be wasted. I guess my target machine to have this run smoothly on would be cheap laptops.

    I'll also look into Spine and other 2D animations solutions. I feel like I've seen that before and the animation looks a bit unnatural compared to manually drawn keyframes though. Of course, I guess there's a tradeoff for everything so maybe it'll work for my game.

    Thanks as always for the help!
     
    Kurt-Dekker likes this.