script or behavior. that is the question
by rennie moffat · in iTorque 2D · 08/09/2010 (12:30 pm) · 3 replies
Hi, I am thinking I already know the answer, but am unsure to implement until I hear some feedback but I have a question.
I have a behavior, 171 lines in length. In each of my levels, this behavior is attached to 100s of objects. I am wondering, if I converted the behavior to a single script that is called via game.cs would this save me a heck of lot of computing power (mainly at loadLevel)? or just bit or none at all?
I have a behavior, 171 lines in length. In each of my levels, this behavior is attached to 100s of objects. I am wondering, if I converted the behavior to a single script that is called via game.cs would this save me a heck of lot of computing power (mainly at loadLevel)? or just bit or none at all?
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
And yes, 100's of objects. I have had to use timeAdvance to push my game speed up. The way my game is designed I can not go back now. So you think that behaviors, vs script wont do much or will?
08/09/2010 (1:07 pm)
Yes, it has no onUpdates, but does use onCollisions, however the command is simply if this class, set this object in this position, if that class, set position. I have 7 potential collision classes, each sets another object in position band is quite sporadic. Figure 7 objects, over hundreds, collision rate, per object is very low. So I would think, not too demanding. And yes, 100's of objects. I have had to use timeAdvance to push my game speed up. The way my game is designed I can not go back now. So you think that behaviors, vs script wont do much or will?
#3
As I mentioned I don't use behaviors so I don't know much about them, but I think scripts are probably more flexible because you can use timers to control when things happen in the game, which gives you complete control over the timing of events.
BTW, this time I agree with Marc's comment about 100's of objects. I've experimented quite a bit and I've usually found that things really start to slow down and lag when the number of active objects is more than 50 or so. Do all of your objects need to be active all the time, or could you work with a smaller subset at a time? It would be much better if you could organise your game somehow, so that you only have 50 or so objects that are active at any given time.
08/09/2010 (7:09 pm)
I don't use behaviors so I can't offer much help regarding behaviors vs scripts. The only bit of advice I can think of is to do with onCollisions. You may be doing this already, but I would recommend using layers to minimise the number of collision callbacks. If you allocate different layers for certain groups of objects, you can then eliminate collision callbacks for collisions that are not used in the game. For example, if object A should never collide with object B, use different layers for those objects and then use collision layers to elimate those collisions. Otherwise you could be firing lots of unnecessary onCollision callbacks, which would add unnecessary load on the CPU.As I mentioned I don't use behaviors so I don't know much about them, but I think scripts are probably more flexible because you can use timers to control when things happen in the game, which gives you complete control over the timing of events.
BTW, this time I agree with Marc's comment about 100's of objects. I've experimented quite a bit and I've usually found that things really start to slow down and lag when the number of active objects is more than 50 or so. Do all of your objects need to be active all the time, or could you work with a smaller subset at a time? It would be much better if you could organise your game somehow, so that you only have 50 or so objects that are active at any given time.
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
where it will potentially hit you is if you have update functions or onMouse or collision stuff in, in that case it will have massive impact due to the requirement of having it on that many objects.
also, 100s of objects?
you target iphone4 exclusively or forgot that this is no pc and you don't have 2ghz and gigs of ram at hand? ;)