• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Is it necessary to deactivate instances with no code?

L

LilRony

Guest
Hey all,

I'm having some trouble with my game's framerate lately. I don't really know if it's due to the ever-increasing number of rooms, objects and sprites, or just something I'm overlooking.

I've already went through and got rid of as much precise collision checking as possible, and I've cleared the asset compiler, which worked for awhile. There's still one room with a ton of solid blocks and "tile" blocks that just sit there for aesthetics. Whenever I go into it, the framerate drops from 60 to 35 at times...

Should these useless objects be deactivated outside the view? Does it make a difference?

Thanks!
 

kburkhart84

Firehammer Games
Deactivation of objects can help with framerate, if that is what is causing the drop. If you are using collision events, and have a bunch of collision objects, this could cause it. Instead of doing it that way though, if you switch to using separate collision objects from the graphics, you can optimize. For example, for the ground, make a single long sprite(likely scaled) be the collision object. It doesn't have to be visible, and it optimizes whole lines of floor into a single object for collision purposes.

If that doesn't do the trick(though on PC I would think it would), you could switch to using a tile based collision system(look on the tech blog, Mike made a post about it). Or you could keep what you have, but implement a system for deactivating objects. The catch with that, is you have to make sure enemies don't fall through the floor, if you happen to activate an enemy that is close enough to activate, but the floor is not...you have to work around it. This is why I suggest the first option I mention above.

Of course, you really need to be sure of what is actually causing your framerate loss. You can optimize all day, but if it isn't the bottleneck, you will still lose your frames.
 

MCHLV

Member
+1. deactivating should help, but can be tricky. kburkhart84's advise is great for platform game : separating collision and graphics. Have a look to this : https://forum.yoyogames.com/index.php?threads/optimized-collision-with-tiles.236/
Except for the number of objects, do you see any other difference between this room and the one that are working ok ?
Do your objects have step event or draw event ?
Maybe you can try profiling to check where this come from : http://www.yoyogames.com/blog/44
 
Last edited:

TheouAegis

Member
You can reduce the number of objects by combining all connected ones. If you get the object count down low enough, the deactivating would be unnecessary.
 

RangerX

Member
First step would indeed be to use the profiler and make absolutely sure of what is slowing down the game. If its indeed the number of objects active at the same time, an activation/deactivation system is easy to pull off. And reducing the number of objects and use of "solid" as much as possible is always good.
 
Top