Z
Z
Zefirot2021-10-23 11:48:33
Unity
Zefirot, 2021-10-23 11:48:33

What is the best way to do a mass update?

Here I have a bunch of prefabs in which their elements move inside according to the update, for example, something like a planet and satellites fly around.

private void AngleMove(){
        TestAngle -= Time.deltaTime;
        TestPosZ -= Time.deltaTime * 30f;
        for(byte n = 0; n < 8; ++n){
            switch(n){
                case 1: AnglePlus = 7.6f; break;
                case 2: AnglePlus = 23.3f; break;
                case 3: AnglePlus = 15.95f; break;
                case 4: AnglePlus = 0.25f; break;
                }
            var x = Mathf.Cos ((TestAngle + AnglePlus) * 0.2f) * (transform.localScale.x / 3f);
            var y = Mathf.Sin ((TestAngle + AnglePlus) * 0.2f) * (transform.localScale.x / 3f);
            this.ArrayTestObject[n].transform.position = new Vector3(x + transform.position.x, y + transform.position.y, 1f);
            this.ArrayTestObject[n].transform.rotation = Quaternion.Euler(0, 0, TestPosZ);
            }
        }

And then there will be a lot of such prefabs and these small elements will move along the same coordinates.
The question is, what is the best way to do it, to use this method in each prefab or to execute this method in one control script, and I will take only the calculated coordinates for prefabs?
At the moment, I don’t see a difference, but in the future, moreover, there are several similar methods in prefabs ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pragma Games, 2021-10-30
@Zefirot

The second way is better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question