I would have something to show, but everything i try just seems to get worse and worse.
Basically i have lets say 50 objects on screen, i want to get all objects with tag, save them to an array along with their locations.
I want to save that (i have the save part sorted) and load it back in when i carry on playing.
all objects are rigid bodies and are spawned from a prefab.
Any help with syntax for the loops and arrays would be great as im really struggling.
i’m using c#.
The Corutine part is for testing only
using UnityEngine;
using System.Collections;
public class test7 : MonoBehaviour {
public GameObject[] objs;
public Vector3[] origPos;
public bool moveObjs = true;
void Start(){
objs = GameObject.FindGameObjectsWithTag("Whatever");
origPos = new Vector3[objs.Length];
for (int i = 0; i < objs.Length; i++) {
origPos _= objs*.transform.position;*_
* }*
* StartCoroutine(Move ());*
* }*
* IEnumerator Move(){*
* if(moveObjs){*
* yield return new WaitForSeconds(2);*
* for (int i = 0; i < objs.Length; i++) {*
_ objs*.transform.position = Vector3.zero;
}
moveObjs = false;
}
if(!moveObjs){
yield return new WaitForSeconds(2);
for (int i = 0; i < objs.Length; i++) {
objs.transform.position = origPos;
}
moveObjs = true;
}
}
}*_