i got this script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour
{
public Vector3 scaleChange;
public float X;
public float position;
public GameObject Spawnpos;
public Transform spawnposT;
public float timefromlastspawn = 0f;
public GameObject Prefab;
// Start is called before the first frame update
void Start()
{
scaleChange = new Vector3(1f, 1f, 1f);
}
// Update is called once per frame
void Update()
{
X = spawnposT.transform.position.x;
Prefab.transform.localScale = scaleChange;
position = Random.Range(-10, 10 * Time.deltaTime);
timefromlastspawn += Time.deltaTime;
if (timefromlastspawn > 5f)
{
SpawnBird();
timefromlastspawn = 0f;
}
}
public void SpawnBird()
{
Prefab.transform.parent = Spawnpos.transform;
Instantiate(Prefab, new Vector3(X, position, 0), Quaternion.identity);
}
}
and it spawns objects but for some reason the y position is always 6.7 and something.
anyone know the reason?