Forum rules - please read before posting.

Considerations about weight build/speed on a 2d graphic adventure game

Hi everyone, with this discussion I'd like to sharing the results of the tests I'm making on my 2d graphic adventure project to improve speed and weight build. If someone has more efficient solutions or suggestions, you're welcome.

Some technical notes:

  • I'm working with Unity 2017.1.1f1 and AC 1.66.1 on a 2d graphic adventure
  • At the moment my project has 1 main Character with the following animations:
    Talk x8, Animated Idle x8, Static idle x8, Talk x8, Take x16 (down and middle positions), Use x8, Walk x8, 20 custom animation (only one direction).

  • 40 rooms, some with internal animations other without.

  • 10 NPC with about (4-5 animations (Idle, Talk, Take, Give))
  • 3 videos (intro, endings, etc)
  • 450 audio clips for dubbing
  • I test the builds on a notebook Intel Core I5 337u 1,8 GHz + 6 GB Ram + Nvidia GeForce GT 630M + HD Hitachi 640 GB + Win10.

Actually I'm trying to reduce the weight of the textures (above all animations) because I noticed (using Unity profiler), the most part of memory used is due to the amount of textures. So in these tests I'm not working on audio (at the moment I'm not using asset bundles, but the speech audio management script ( https://adventure-creator.wikia.com/wiki/Auto-assign_custom_speech_audio)). When I tried to use the automatic speech options I noticed a big slowndown in the switching between scenes, but this script helped me. Probably asset bundles give a better result (also in memory consuming), but I have to test it.

The first thing I did was to evaluate if using sprite packer or sprite atlas. I think the options Mode in Editor, Always Enabled and Always Enable (Legacy Sprite Packer) are not compatible, so, or sprite packer or Sprite Atlas. I tested sprite packer for all animations (players and animations in rooms). It was good: fast switching between scenes and reduced memory consuming (on my project textures consumed at start 2 GB). Then I tested sprite atlas (again both for players and animations in room): better then sprite packer: fast switching between scenes and more reduced memory consuming (on my project, with sprite atlases, memory consuming for textures was 1,45 GB).

To reduce weight build I tested the RGBA Compressed DXT5 (and DXT 1) compared with RGBA Crunched DXT5 (and DXT1) for animations: with the Compressed my build was about 3,2 GB, while the second one 2,65 GB. I can't see any deterioration in quality and the first start of the games was a little bit fast.

Then I tested the Sprite Atlases with the two formats (RGBA Compressed (DXT5 and DXT1)) and RGBA Crunched (DXT5 and DXT1). Also in this case I saw the weight build better with the second compression: from 3,2 GB to 2,6 GB and no deteriorations. Important: The first time I created Atlases I put them in the resources folder: NOT GOOD. I saw a big slowdown in switching between scenes. So I move them in another folder (called Atlas) and switching came back all right.

If anyone have more suggestions to improve textures or if someone wants to correct if I said something wrong as conclusions of my tests, you're welcome.

Comments

  • Now I'm looking to solve another issue: the first time the game start it take a bit of time (actually about 25 seconds on the notebook described above). I think there are two problems:

    • the prefab of the main player (where inside there are all the animations)
      • the sound clips for dubbing.

    I hope to solve the second one with asset bundles, and, for the first one I follow some Chris' suggestions: I can use "local players" with a duplicated animator controller where, for these players I maintain the base animations plus the custom, while from the prefab, I delete all custom animations. I think it's a good starting point: the little issue is that for local players, the system had to load again the basic animations. I'd like to load at the first time only the base animations (idle, talk, walk, etc) and then, inside the room, only the custom, without reload also the base animations. I'm working in this direction now.

    If anyone has other suggestions or trick to reduce the first load of the game, it helps me a lot. Thank you very much.

  • One other way to reduce the load of animations on the Player controller is to rely on Timeline to play "one off" cutscene animations so that they can be removed from the Animator Controller.

    Though this is typically a better approach with 3D games, you may get lucky here too since you say such animations are one-directional.

  • Thank you very much Chris, I'll try.

  • Thank you Chris, I'm trying the timeline solution and it seems to work: I create a new GameObject in scene, then I "attached" the timeline (director component), and inside it I link the custom clip. Then, I replace the previous Action (Character/Animate/Play Custom) with the new one (Engine/Control Timeline/Play). I delete the status from the animator controller and the memory to load textures reduced. Very well.

    But I have some little (I hope) issues: my prefab player has a Follow Sorting Map script, but I can't link the Sorting Map in scene with the new GameObject (containing the timeline).
    Also the position is quite a issue. Actually I put the new GameObject nearly the point where animation has to start, but it's not so precise (the player walk to the marker, and, from it animation start). Maybe I solved using Object/Teleport, but I'm not so sure (Sorting Map change the proportions).
    The last one: visibility of the new GameObject: when the new GameObject plays the timeline I have to hide the prefab and show GameObject, and, when animation ends, viceversa. I bypass the problem using a remember visibility script both on new GameObject and on player prefab.

  • Try animating the Player itself in the Timeline - not a separate GameObject. He should be then able to respect the SortingMap etc (so long as you don't override his scale values in Timeline).

    If you're using a runtime-spawned Player prefab, you can automatically rebind him to the appropriate track by checking Remap bindings? in the Engine: Control Timeline Action. The 3D Demo does this in the Unity 2018.3 release of AC for its opening and closing cutscenes.

  • Hi Chris, thank you for suggestions. I made some tests on my 2d project. The first one is with a "local player": I copy the prefab in scene, create a director on it, create a timeline with a clip and the use Engine/Control Timeline and it works. But I need a local player (so I think all the basic animations are upload everytime when I enter in the room).
    The second one is using remap binding: I create a GameObject in scene and attached a Playable director component and, in timeline, the same clip of the first test. So in this case I haven't a local player. Then I checked "Remap bindings" and "Bind to Player", but it seems not to work: I have a new player (not proportioned) behind the actual player ( here the result: https://drive.google.com/open?id=14tzvN8dx4zhWrfDZ6N9zH9ZcXV5r4Q0s). Animation starts but the player is always behind the player and objects (like if it ignores the layer order), and is always visible, also when animation ends (like if it remain attached to the player also if I switch between rooms). Am I missing something?

  • It's hard to say without seeing images of your actual setup - not just the result.

    Try sticking to the local player route, but keeping the Playable Director on a separate GameObject (don't attach it to the Player directly). I don't follow your issue with the first test - you say you need a local player, but that test involves one. What's the issue there?

  • Hello Chris. The first test hasn't a real issue, because all works perfectly. But my worry is about memory consuming: with local players I think (please correct me if I'm wrong) every time I switch in a room (where there'a a local player) memory has to load all the basic animations (walk, talk, use, etc) + the custom one. So I think I optimized the first game start (where on the prefab there are less animations), but then I have more memory consuming in switching. So I'm searching to find a solution to load the basic animations at the start and the custom only in the room they need. So I think timeline is a good solution if I can attach it on the player (but without copy in the local scene).

    And so these are my steps to create a GameObject with a timeline and try to bind to the player (prefab).
    Player settings (root+child):
    https://drive.google.com/open?id=1bL-CZr9TrMgYTAPds9p8R97SEjR90W43
    https://drive.google.com/open?id=1L83zMkRxUiEW15fGBRfP4Pd1dCnug9rv

    Steps to create timeline (with a clip) and Action:
    https://drive.google.com/open?id=1N88o8R5yzehBPSX_8NETDZeKdf8qdpAP
    https://drive.google.com/open?id=1IjdiFfrJR01U7FyOyVOPS8sw5gVo0_RL
    https://drive.google.com/open?id=1f1aDcJBm8V76gT4ekLGe4_t4KWHiXTuX
    https://drive.google.com/open?id=1dceEJlH4ptTRCCo6YQd70fXNzgag-BrR

    But the result is that I show, like if the clip works behind the player (and not proportionate) and it remains attached to the player also when animation finished.

    If I copy the prefab player in scene (and bind to the local player child in the action Engine/timeline control) all is right, but I have a local player (and I think to memory consuming to load again the basic animations).

  • It's not clear from your screens what animation you're playing, but you want the Timeline to override your regular Player sprite - not create a second one.

    One thing to consider when working in 2D is that when animating the sprite, you don't want to bind it to the player's root - but rather the sprite child.

    Assuming that the animation track is updating a Sprite Renderer component attached to the GameObject the track is bound to, uncheck Bind to Player?, and assign the sprite child into the field. That should record a Constant ID on the child (make sure it has Retain in prefab? checked), so you can then remove the prefab from the scene, and the link will be restored when spawned at runtime.

  • Fantastic Chris, now it works perfectly without the local player. The issue was I can't assign the sprite child to the "Build to" field, because the sprite child didn't show in the options when I opened the popup menu to select. But I solved forcing the field (simply drag 'n drop the sprite child into the field). Thank you again for the help.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.