Hi all
I’ve been pouring over pages from the forum and google on things like broadcast messages and events, and arrays. So much so that now I’m more confused than ever.
I have in my game a bunch of gameObjects that spawn and are then moved to a predefined place in the scene. However, whenever they spawn (up to 60 at a time) and move, I get a terrible drop in frame rate that I’m attributing at the moment to the fact that I’m sending out a broadcast message to each of them on spawn. This is what I’m doing:
Item1 = the Prefab of the object being spawned using PoolManager ///function SpawnMove() {
for (var item1: Transform in PoolManager.Pools["Item1Pool"]) {
switch(true) {
case b_a1 :
b_a1 = false; item1.BroadcastMessage ("Destination", v_a1); item1.BroadcastMessage ("MoveMe", true);
break;
case b_a2 :
b_a2 = false; item1.BroadcastMessage ("Destination", v_a2); item1.BroadcastMessage ("MoveMe", true);
break;
..... And so forth 58 more cases....
default:
break;
............etc
}
On the “Item1” prefab gameObject, there is a script that contains:
function Destination(whereAmIGoing : Vector3) {
this.destinationT1 = whereAmIGoing;
}
So, am I right in thinking that the above method is resource-heavy and would be the cause of the lag (up to 10fps drop!) Also, on the 3Gs and 4, it seems that possibly I’m getting memory leaks with this as well, as the optimal frame-rate of 30fps never returns, and again, I’m thinking that it has something to do with all those broadcast messages.
As mentioned I’ve been looking at events/array lists etc, but they’re not my strong point, and arrays make my head hurt!
Any advice on direction would be appreciated
:-o