Welcome. I also created this script to move objects where I need them in the scene, but I have a small problem. If I add a single object in object to move, the object moves, but if I add two or more objects, it doesn’t work anymore, the objects stay in place and I have to press the button twice to make the move work. I tried to add the respective child objects to a main object and it still does the same**“**
using UnityEngine;
using System.Collections;
using UnityEngine;
public class MoveObject : MonoBehaviour
{
public GameObject[] objectsToMove;
public Vector3 targetPosition;
public Vector3 targetRotation;
public GameObject RaceScripts;
public GameObject RaceCampaign;
public GameObject Race;
public GameObject RCCCanvas;
public void MoveAndRotate()
{
foreach (GameObject obj in objectsToMove)
{
obj.transform.position = targetPosition;
obj.transform.rotation = Quaternion.Euler(targetRotation);
}
StartCoroutine(ActivateRaceComponentsWithDelay(0.1f));
}
private IEnumerator ActivateRaceComponentsWithDelay(float delay)
{
yield return new WaitForSeconds(delay);
ActivateRaceComponents();
}
private void ActivateRaceComponents()
{
RaceScripts.GetComponent<Timer>().enabled = true;
RaceCampaign.SetActive(false);
Race.SetActive(true);
RCCCanvas.SetActive(true);
}
}