Hey guys,
I have an issue with my game running slowly. My question is should I have one script updating the objects that are active or should I have each object check to see if it’s active then update itself?
Right now I have about 50 GameObjects with almost all of them with their own update(). I don’t know if this is why my game is running slowly. Most of the objects are bullets that update() looks like this:
void Update () {
if (isActive && state == Projectile.State.Active) {
BulletMove ();
}
}
protected void BulletMove () {
transform.Translate(0f, 0f, speedProjectile * Time.deltaTime);
currentDistance += speedProjectile * Time.deltaTime;
if (currentDistance > distanceMax) {
Deactivate ();
}
}
I have a couple of missiles that do the same thing. I also have 5 enemy ships that do the same thing. These just check to see if their state is active then they update.