High lag spikes of ping and CPU / How to see how active scripts are in causing lag?

Hey developers. When I test my game in studio, I am getting spikes of ping and CPU almost every 2-3 seconds. So I am trying to see what excatly is causing that lag. My game though is quite huge, so like I can’t just look through ‘all the scripts’. I need to narrow it down to if it’s a modeling issue/render issue, or a scripting issue and where it’s coming from. Now I know that there is tools for this, but I don’t understand them well, such as the developer console. So any help on figuring out the source of my lag is appreciated!

Some Videos:
(Ping)

(CPU)

So fire up the game, press F9 and head in to the Dev console. In the top-right, there is a drop down, select scripts & this will show you all (green) and sleeping(?) scripts:


You need to consider both the Activity (%) which if it is above 1 frequently needs to be reviewed and consider how much work the script is doing and if it is needed to actively fire/work as much as it is.
Secondly Rate shows how frequently the script is firing. In my example ‘Animate’ has a high Rate, but low Activity. It is controlling the NPC animations as they move and change state from Idle to Walking.
This game did have a problem with lag with projectile throwing. When the projectile is spawned, it contains a script which controls it motion & collision detection. I noticed the Rate for this script increased over time so I knew there was an issue. I discovered that I was not disconnection the projectile motion loop so the script kept running. Nice discovery solely using this console

4 Likes

Thank you so much for your help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.