Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Ошибка в скрипте на Unity3d

Viktor Wot Ученик (123), на голосовании 2 недели назад

Не понимаю в чём проблема. Необходимо чтобы объекты расставлялись рандомно по трём заданным точкам
Голосование за лучший ответ
Toxop Мыслитель (5080) 1 месяц назад
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
}
}
Viktor WotУченик (123) 1 месяц назад
Теперь другая ошибка
Похожие вопросы