Large CPU spikes during boss fight

0 favourites
  • 9 posts
From the Asset Store
Fully animated spike ball characters game sprite.
  • A few days ago I made a thread talking about lag that I was getting during the boss fight I was working on. I didn't really understand too much about what was going on, so the thread is kind of confusing and I deleted a bunch of my own confusing replies and it was getting a bit messy. But I did more research and did some more rigorous testing and now have a clearer idea of what's going on and what to ask.

    The problem seems to be that every time my boss' attack pattern loops, the CPU usage increases. It won't be noticeable during the first loop, but every loop it gets worse until I eventually observed that CPU usage spikes to 100% and the frames drop to less than 20.

    But there's kind of just some oddities with it all. For instance, if I disable all of my event groups besides the ones that keep the player and boss moving, the CPU usage remains constant and low and there is no perceivable lag. I figured I could solve the issue then by just disabling unused groups during the boss fight. However, when I enabled some groups that are essential to the player losing lives and receiving game overs, the lag is back and is just as worse as all the groups being enabled.

    Additionally, no matter what event groups are enabled or disabled, if I take the boss' "dashattack" out of his attack cycle, there is not lag or significant CPU usage increase. I've tried temporarily disabling parts of that attack, such as a timer and events that cause him to play a skidding animation, but neither of those prevent that lag from happening. So to me it would seem like that attack is what is responsible for the lag, but like I said before, if I disable a bunch of event groups that attack doesn't cause lag which is puzzling.

    I've been going at it for a few days now trying to figure out what the primary cause is, but haven't been successful.

    Thanks in advance for the help. This is the first time I've run into a problem like this. It's definitely been a learning experience!

  • I finally sorted out my subscription and took a look, it is as I said in a previous thread the events are running every tick hundreds of times. Adding a trigger once to what you have will kind of work but then it doesn't reset the attack. You need to find a way of having it trigger once each time and cycle round so try a different structure.

  • So I need to reset the attack in addition to the trigger once condition. How do I reset it? Is that through some sort of action or condition?

  • Yeah the batch waiting for signals every time you receive a signal it runs the next bit 'every tick'. Adding a trigger once fixes it but it doesn't return to phase 1 start. In my opinion better to give up on that structure of wait for signal, go to the actual attacks on animation finished and set the next animation in the sequence there for a better structure.

  • Gotcha. I'm away from my computer right now but I will definitely take a look at that. Thanks so much for the help!

  • Yep. It was definitely that. For some reason I guess I thought that even though the event had no condition that it would wait for the signal without activating. That definitely helped but now I've realized that, even without entering the boss fight, my CPU usage crawls up gradually. I'll just have to go through and edit some events so that they aren't firing off all the time and make sure I'm more careful about that in the future. Thanks again for your help!

  • One quick thing. Is there a way to track when events are triggered and how much they are triggered? I know there's a way to log things in the console, but is there a way to do that for every event all at once? It would make it easier to see what events are being constantly triggered and driving up the CPU usage.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't think so, I was using browser log to check. You have a lot of events running every tick though so CPU usage looks fairly high. I think because you have all the events sheets linked it is probably running most events in your game all the time. FYI, no condition is the same as using 'every tick'.

  • I went through my events and found all the ones that were waiting for a signal every tick or ones that had conditions that were pretty much always true. Just to test it out I disabled them all and the CPU usage remained constant at about 8-12%. Now I just need to make those events more specific with clearer conditions and that I think it should all be good to go!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)