Dossier complet
This commit is contained in:
34
Droid 2/Assets/Meteorite.cs
Normal file
34
Droid 2/Assets/Meteorite.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user