My game has started to lag / jitter - How do I locate whats causing this from the profiler?

Hi,

Today, I noticed that my game has started to lag or jitter during gameplay. I dont remember adding anything graphic intensive recently and yet it started doing this today.
I know that I can locate this using profiler but I have never used the profiler before and dont know what am I supposed to be looking for.

Here is a screenshot of it during gameplay. I assume the large purple UI spikes are causing the lags? Can someone please give some more insight into this?

The high resolution version of the image is here: https://ibb.co/yqw6hvH
Thank you

Ok so I read up a bit more on how to read the profiler and I found out that the hierarchy window is much more helpful than the time line.

Well, the purple spikes are “Transform.GetScene” which is being called 97 times a frame. This would explain the lag, but I cant seem to locate the source of this. Nor can I find anything on Google for Transform.GetScene. And I dont ever remember adding anything like this to one of my scripts.

How would I determine the source of this?

Thanks

Looks like you have a complex world space canvas that does change.

1 Like

You’re right, Thank you.

I did have world space canvases attached to every enemy in the scene that showed the health bar above each enemy.

I did not know this was such a stressful operation?

But healthbars are so common in every game… how do people achieve it without a world space canvas and without causing the game to slow down?

Thanks

Im not sure if it helps but you can try to combine all the canvases to one.

1 Like

There are a lot of methods to make healthbars, you can use 3d models that scale based on health that simply rotate towards the camera. Or you could use shaders. No need for canvases in either way