Forum rules - please read before posting.

Any tips for reducing lag in a very busy 2D point and click scene?

I have a very busy scene so I know that a lot of the lag is going to stem simply from there being just so much going on, but I was wondering if there are any settings I can look into first before making any drastic changes. All of my animations are skeletal animations and I want to say I have upwards of 100 things going at the moment. I have 2 particle systems and 7 characters that are on looping paths. It's a 2D point and click if that matters at all. I have probably 60-70 interactable objects (typical look, use, talk).

I've considered using some different camera zooms to get some of the things off screen and stopping their animations (if that's a thing I can do). I have considered going in and making the bone structures on objects simpler since I know some are over-engineered at the moment (I'm not sure if that makes a difference). I have also considered the more drastic and far less preferable method of just chopping the scene into two.

If anyone knows of anything I can look into that might ease the burden on slower computers that'd be great. Thanks!

Comments

  • What kind of lag are we talking about? Is it noticeable at all times, or only when performing certain actions, e.g. pathfinding?

    I recommend first running a Deep Profile analysis using Unity's Profiler - that should give some clue as to where the major bottlenecks are. If you're unclear about any of AC functions that are being called, share them here and I can take a look.

    It would also be worth - at runtime - selectively disabling various elements of the scene, and seeing which ones result in the biggest improvement to narrow things down. At the moment, it's not entirely clear if this is directly AC-related or not, so we'll first need to learn the biggest causes of the problem are coming from.

  • Thanks for the reply. This is my first time working in Unity so bear with me a bit. I usually work in text-based stuff so this is all new.

    I did end up splitting the scene which helped a bit. And I changed the mouse to hardware which obviously got rid of the mouse/input lag. It's hard for me to say what sort of lag it is, the people testing it mostly said they noticed it with the mouse (as in it ran smoother when the pause menu was up), but that things did seem a bit "slower and less fluid" in terms of the game itself.

    It works even with the full scene on my machine just fine which makes the selective disabling thing more difficult. I'll have to see if I can get another machine up and running with my spare parts to test.

    The profiler definitely shows jumps when pathfinding which I imagine is expected. I start the scene in the top right corner zoomed in, so when I hit the camera zoom out everything escalates which, again, seems expected. Switching scenes to the bottom scene makes it jump again.

    In CPU usage "Scripts" is off the charts. I'll put up a screenshot of the analysis I got for these frames I ran. Looks like scripts is my culprit. I'll have to do a deep profile after my next computer reboot. I have a bunch of stuff running and it wasn't happy.

    https://i.imgur.com/16kstlh.png
    https://i.imgur.com/Y4auRXK.png

    Those are from running the analysis in the Unity Editor. I finally got it running on a dev build but it was lagging pretty hard trying to do the deep profile. Will have to run one next time I reboot.

    I guess I was wondering if having skeletal animations with more bones than necessary could be causing the lag, or if that's negligible next to there just being too many animations themselves. Or if I'm just doing something completely newbie-ish to hinder the workflow. It's obvious that "Scripts" are the issue, but not sure what all that entails. If I have some rogue thing running in the background hampering me, or if that would be normal with so many things moving.

    I've also got an mp4 of the scene if it helps seeing what's all going on. https://drive.google.com/file/d/1ElERZ7BEQ1Zv61zN8HxYydNh4lr5UxLP/view

  • Looking more closely it seems most of the script calls are SpriteSkin.LateUpdate() [Invoke]. A lot of instances of it, like 169, taking 188.98ms. So I'm guessing that has to do with the animations.

  • Having dug even more... looks like it might be Unity's 2D animation suite causing the issues and if I go through and make them into traditional sprite sheets it might run better. Was kinda hoping that wasn't the case... Unless you see something else crazy going on, I think that's my culprit.

  • Another update... maybe I should have waited until doing all my Google-Fu. I added Burst and Collections packages and now it's running much smoother. That top graph looks like this now. https://i.imgur.com/QggadRV.png

  • edited February 2021

    It sounds like it was indeed down to the 2D animation code, but if you ever have need to, you can change the "Timeline" option at the lower-left of your last image to "Hierarchy" to get a drill-down of the exact scripts/functions that are causing you bottlenecks.

  • Awesome, sounds good. Thanks for the help! You got me to the right place to narrow down what was going on.

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.