STALKER
Просветленный
(43933)
5 месяцев назад
random замените на randomX
GameObject Enemy - Instantiate(obj, whereToSpawn, Quaternion.identity);
на
GameObject Enemy = Instantiate(obj, whereToSpawn, Quaternion.identity);
Visual studio подсвечивает все ошибки, пишите в ней.
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour
{
public GameObject obj;
private float randomX;
Vector2 whereToSpawn;
public float spawnDelay;
float nextSpawn = 0.0f;
void Start()
{
}
void Update()
{
if(Time.time > nextSpawn)
{
nextSpawn = Time.time + spawnDelay;
random = Random. Range (-8, 8);
whereToSpawn = new Vector2(randomX, transform.position.y);
GameObject Enemy - Instantiate(obj, whereToSpawn, Quaternion.identity);
Destroy(Enemy, 1.7f);
}
}
}