How do you guys keep framerate with 30-50 enemies?
by Cosmic Logic · in Torque X 2D · 10/23/2010 (9:06 pm) · 9 replies
I'm having big trouble with my framerate lately and I'm not sure how to make a game with 30-50 enemies on one screen.
Here's a video for the gameplay:
http://www.youtube.com/watch?v=Mvo5awZNEQM
(Since the video I've taken out the enemy ranged attacks, and yes I do suck at my own game :) )
I'm testing right now the later levels that have 30-50 enemies on the screen at once, and firing if you get to close.
At the moment I'm getting framerate drops around 25+ with no firing.
The AI is minimal. Once the enemy is spawned I find it's two moving end points and then store their path in a vector stack. Then it just moves between those two end points.
They are just cloned with a timer I've built in to a component by using the .Clone() method.
The only particle effects I have are the player's melee+ranged attack and the pickups. They are all single particles as well.
I've profiled my a* with the torque profiler and it contributes fractions of a millisecond.
Pooling just makes the cloning faster right? (I'm pretty sure that's not a problem)
Any pointers? Where should I look for optimizing?
PS: The framerate keeps pretty well in the video and on my PC, it slows down on the xbox.
Here's a video for the gameplay:
http://www.youtube.com/watch?v=Mvo5awZNEQM
(Since the video I've taken out the enemy ranged attacks, and yes I do suck at my own game :) )
I'm testing right now the later levels that have 30-50 enemies on the screen at once, and firing if you get to close.
At the moment I'm getting framerate drops around 25+ with no firing.
The AI is minimal. Once the enemy is spawned I find it's two moving end points and then store their path in a vector stack. Then it just moves between those two end points.
They are just cloned with a timer I've built in to a component by using the .Clone() method.
The only particle effects I have are the player's melee+ranged attack and the pickups. They are all single particles as well.
I've profiled my a* with the torque profiler and it contributes fractions of a millisecond.
Pooling just makes the cloning faster right? (I'm pretty sure that's not a problem)
Any pointers? Where should I look for optimizing?
PS: The framerate keeps pretty well in the video and on my PC, it slows down on the xbox.
#2
Dead enemies are deleted properly for sure. It slows down even if I haven't killed anything yet.
10/23/2010 (11:40 pm)
I'm not sure if I'm using pool with components right, when I enable it I get null physics component crashes. Pooling only helps with spawning anyways, right? I don't think the object pool is used anywhere else. I'll take a look around, maybe it is.Dead enemies are deleted properly for sure. It slows down even if I haven't killed anything yet.
#3
((T2DSceneCamera)playerFollowCamera).FarDistance = 10000f;
10/24/2010 (10:59 am)
Did you set the camera far distance? ((T2DSceneCamera)playerFollowCamera).FarDistance = 10000f;
#4
I'll keep poking around.
EDIT:
I think I might have found it. I was playing with lights to tint enemies a while back and forgot to delete the lightcomponent off of the template. Perhaps that's the problem. I'll re-edit once I get a chance to run it on the xbox.
Edit 2:
That definately helped. Since I got rid of those it's much faster. Still a little choppy but I'll find the bottom of it.
10/24/2010 (6:29 pm)
I've already got it set to 1000, and that shouldn't make any difference unless I have more than 1000 objects on the screen. I stepped through the rendering phase and I've only got about 100.I'll keep poking around.
EDIT:
I think I might have found it. I was playing with lights to tint enemies a while back and forgot to delete the lightcomponent off of the template. Perhaps that's the problem. I'll re-edit once I get a chance to run it on the xbox.
Edit 2:
That definately helped. Since I got rid of those it's much faster. Still a little choppy but I'll find the bottom of it.
#5
Also, how big are your images, are they the size you are rendering at, lots of resizing might do it to.
But generally speaking, this is surprising, because I rarely run into frame rate issues unless i'm doing something I know is notorious for causing low frame rates in game engines :)
10/24/2010 (6:43 pm)
Cosmic, how are you doing collision. If you have tons of sides to each polygon, with rigid physics, and every object colliding with every object, you could easily slow down your frame rate with as few objects as you have there.Also, how big are your images, are they the size you are rendering at, lots of resizing might do it to.
But generally speaking, this is surprising, because I rarely run into frame rate issues unless i'm doing something I know is notorious for causing low frame rates in game engines :)
#6
All movement is a mod of a* moving along a grid. (I profiled my a* as well and all of the calls in a given period of time cost fractions of a millisecond)... Although, how my astar works is that I create a new astar object every time I create a path... Maybe they're not being disposed properly. Off to CLR!
I'm going to hook up a framerate counter and see what I'm running at.
10/24/2010 (7:00 pm)
The only collision I have is projectiles colliding with enemies and enemies colliding with the player. Enemies don't collide with eachother at all and the walls only collide with projectiles.All movement is a mod of a* moving along a grid. (I profiled my a* as well and all of the calls in a given period of time cost fractions of a millisecond)... Although, how my astar works is that I create a new astar object every time I create a path... Maybe they're not being disposed properly. Off to CLR!
I'm going to hook up a framerate counter and see what I'm running at.
#7
Have you tested the game on the xbox or another computer? Possibly a computer issue?
10/27/2010 (3:22 am)
Hi Cosmic,Have you tested the game on the xbox or another computer? Possibly a computer issue?
#8
Turns out I found a big part of the problem.
I had Pino's 60FPS limiter enabled even after I got out of the menus. That was just clogging my game.
Now I just get little hickups every second or so.
10/28/2010 (5:52 pm)
It runs fine on the computer. No slow down at all. The lag is on the Xbox.Turns out I found a big part of the problem.
I had Pino's 60FPS limiter enabled even after I got out of the menus. That was just clogging my game.
Now I just get little hickups every second or so.
#9
10/31/2010 (8:41 pm)
I recommend debugging on the XBOX as much as possible. Building your level then making sure it works on the XBOX. I had a huge problem with my last game because my particle effects were way too pc intensive. So start small and deploy to the XBOX gradually to build your level. That way, you know the limits of what it can do.
Torque 3D Owner Bob Dobbs
13th Hour Studios
Pooling ? Pool with components? cleaning up any "dead enemies" with MarkForDelete ?