35 lines
997 B
C#
35 lines
997 B
C#
using UnityEngine;
|
|
|
|
public class Meteorite : MonoBehaviour
|
|
{
|
|
private UIManager UIManager;
|
|
// Direction et force de la chute
|
|
private Vector3 fallDirection = new Vector3(0.5f, -0.7f, 0);
|
|
public float fallSpeed = 10f;
|
|
|
|
void Start() {
|
|
UIManager = FindObjectOfType<UIManager>();
|
|
}
|
|
// Méthode appelée à chaque frame pour faire avancer la météorite
|
|
void Update()
|
|
{
|
|
// Déplace la météorite dans la direction définie
|
|
transform.position += fallDirection * fallSpeed * Time.deltaTime;
|
|
}
|
|
|
|
// Méthode appelée lorsque la météorite touche un objet
|
|
private void OnCollisionEnter(Collision collision)
|
|
{
|
|
// Détruit l'objet touché
|
|
Debug.Log($"{collision.gameObject.name} destroyed by Meteorite!");
|
|
Destroy(collision.gameObject);
|
|
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other) {
|
|
if (other.tag == "Player") {
|
|
StartCoroutine(UIManager.GameOverSequence());
|
|
}
|
|
}
|
|
}
|