multiple objs already generated by instantiate
Get it with Find and move the position to random.range
I'd like to move each object to Random.Range.
Based on the implementation below, it is not possible to move the retrieved object in Random.Range.
It's done, but it gets stuck in one place.
Is there a way to move multiple objs separately?
float x;
floaty;
float z;
x = Random.Range (-200.0f, 200.0f);
y = Random.Range (-200.0f, 200.0f);
z = Random.Range (-200.0f, 200.0f);
aa = GameObject.FindGameObjectsWithTag("obj");
foreach (GameObject tt in aa)
tt.transform.position = new Vector 3(x,y,z);
The current implementation is
·Set random location information to 200 objects
as shown in
·Set random location information for each of 200 objects
If so, I think it would be good.
float x,y,z;
aa = GameObject.FindGameObjectsWithTag("obj");
foreach(GameObject tt in aa) {
x = Random.Range (-200.0f, 200.0f);
y = Random.Range (-200.0f, 200.0f);
z = Random.Range (-200.0f, 200.0f);
tt.transform.position = new Vector 3(x,y,z);
}
© 2025 OneMinuteCode. All rights reserved.