при нажатии на экран каждый раз создается новый объект и как изменит его Vector3 оси Y(и каждый раз этот Y менялся )?

и как указать для newCube началный вектор? новый объект newCube;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Insatantions : MonoBehaviour
{
    public new GameObject gameObject;
    public GameObject Parents;
    public float x = 5;
    public float y = 5.13f;
    public float z = 0;

    void Start()
    {

    }

    IEnumerator AfterTime()
    {
        
        yield return new WaitForSeconds(1);

        GameObject newCube = Instantiate(gameObject, new Vector3(x, y , z), Quaternion.identity);
        newCube.transform.SetParent(Parents.transform);
        //newCube.transform.localPosition = new Vector3(x, y, z);
        y += 0.3f;
    }


    void Update()
    {
        if (Input.GetMouseButtonDown(0) || Input.touchCount > 0)
        {
#if !UNITY_EDITOR
            if (Input.GetTouch(0).phase != TouchPhase.Began)
            {
                return;
            }
#endif
            StartCoroutine(AfterTime());
            
        }
    }
}

Ответы (0 шт):