Handling a large number of objects
by Hilbert Reijngoudt · in Torque Game Builder · 06/02/2011 (1:37 pm) · 3 replies
I'm making a game in which each level contains a large number of enemies.
This all goes well until i turn on the collision callback on all the objects, everything gets really slow..
I think i should only enable the collision callback for the objects that are visible on screen, but i have no idea how to achieve that.
Anybody can help me with this?
This all goes well until i turn on the collision callback on all the objects, everything gets really slow..
I think i should only enable the collision callback for the objects that are visible on screen, but i have no idea how to achieve that.
Anybody can help me with this?
#2
I thought about putting the enemies in a group, but the problem is that i also want them to collide with each other. But they only have to be able to move once they are visible on the screen. That's why i thought maybe i could enable them once they are visible. But i have no idea how to do this.
06/03/2011 (2:12 am)
Thanks for the reply!!I thought about putting the enemies in a group, but the problem is that i also want them to collide with each other. But they only have to be able to move once they are visible on the screen. That's why i thought maybe i could enable them once they are visible. But i have no idea how to do this.
#3
But last week i got it to work and i thought i'd share it here, may come in handy for people with the same problem.
I'm making a game which has 1000+ objects in a single level. These all have to collide with each other and with the player too.
When i tried this i had a frame rate of < 1 because of all the collision detection that was done for all these objects all the time.
So i made a workaround, since i'm walking through my level it's not necessary that all objects are calculating collisions all the time. I Created a trigger and made it twice the size of my camera(just to be sure) and mounted that to the player.
All my objects are in the same group and have sendcollision and physics turned off(the receive collision is on) And when an object enters my trigger i turn on the physics/send collision and put it in the same group as the player. Once the object leaves my trigger i put it back to it's original group and turn the collision options off again(maybe in the future i'll delete them at this point since i can't walk back in my game)
So now the only objects that are calculating collisions are the ones that are inside my trigger. And now my game runs great again!!!! :-D
Just wanted to share this for people who are having the same problem.
06/23/2011 (4:10 am)
It's been a couple of weeks since i worked on this issue. I've been busy with the implementation of other stuff. But last week i got it to work and i thought i'd share it here, may come in handy for people with the same problem.
I'm making a game which has 1000+ objects in a single level. These all have to collide with each other and with the player too.
When i tried this i had a frame rate of < 1 because of all the collision detection that was done for all these objects all the time.
So i made a workaround, since i'm walking through my level it's not necessary that all objects are calculating collisions all the time. I Created a trigger and made it twice the size of my camera(just to be sure) and mounted that to the player.
All my objects are in the same group and have sendcollision and physics turned off(the receive collision is on) And when an object enters my trigger i turn on the physics/send collision and put it in the same group as the player. Once the object leaves my trigger i put it back to it's original group and turn the collision options off again(maybe in the future i'll delete them at this point since i can't walk back in my game)
So now the only objects that are calculating collisions are the ones that are inside my trigger. And now my game runs great again!!!! :-D
Just wanted to share this for people who are having the same problem.
Conor O'Kane
cokane.com