Files
SpaceDroid/My project/Assets/Script/MeteorRain.cs
2025-01-17 13:10:42 +01:00

25 lines
612 B
C#

using System.Collections;
using UnityEngine;
using static UnityEngine.UIElements.UxmlAttributeDescription;
public class MeteorRain : MonoBehaviour
{
[SerializeField] private GameObject Meteorite;
IEnumerator Start()
{
while (true)
{
yield return new WaitForSeconds(3f);
Create();
}
}
void Create()
{
GameObject meteor = Instantiate(Meteorite, transform.position, transform.rotation);
meteor.GetComponent<Rigidbody>().linearVelocity =
new Vector3(Random.Range(-10.0f, 10.0f), Random.Range(-10.0f, 0f), 0);
}
}