neon_run/Assets/Scripts/SectionTriger.cs
2025-09-20 00:10:19 +05:30

20 lines
545 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SectionTriger : MonoBehaviour
{
public GameObject[] roadSection;
public float speed = -100f;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Trigger"))
{
int randomNumber = Random.Range(0, roadSection.Length);
Instantiate(roadSection[randomNumber], new Vector3(0, 0, other.transform.position.z + speed), Quaternion.identity);
}
}
}