Toxop
Мыслитель
(5757)
8 месяцев назад
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Tile : MonoBehaviour // corrected typo in MonoBehaviour
{
public float speed;
[SerializeField] private List<Transform> points = new List<Transform>(); // corrected typo in List<Transform>
[SerializeField] private GameObject obstacle;
// Start is called before the first frame update
void Start()
{
int randomPointIndex = Random.Range(0, points.Count); // corrected typo in Random.Range and randomPointIndex variable name
GameObject newObstacle = Instantiate(obstacle, points[randomPointIndex].position, Quaternion.identity); // corrected typo in Instantiate
newObstacle.transform.SetParent(transform); // corrected typo in SetParent
}
// Update is called once per frame
void FixedUpdate() // corrected typo in FixedUpdate
{
transform.Translate(Vector3.back * speed * Time.fixedDeltaTime); // corrected typo in Translate and fixedDeltaTime
}
}
Не понимаю в чём проблема. Необходимо чтобы объекты расставлялись рандомно по трём заданным точкам