28 lines
844 B
C#
28 lines
844 B
C#
|
using UnityEngine;
|
|||
|
|
|||
|
public class BlackHole : MonoBehaviour
|
|||
|
{
|
|||
|
// Vitesse de rotation du trou noir
|
|||
|
public float rotationSpeed = 10f;
|
|||
|
|
|||
|
// Méthode appelée à chaque frame pour faire tourner le trou noir
|
|||
|
void Update()
|
|||
|
{
|
|||
|
transform.Rotate(0, rotationSpeed * Time.deltaTime, 0);
|
|||
|
}
|
|||
|
private void OnTriggerEnter(Collider other)
|
|||
|
{
|
|||
|
// Vérifie si le droïde ou tout autre objet entre dans le trou noir
|
|||
|
if (other.gameObject.CompareTag("Player"))
|
|||
|
{
|
|||
|
Debug.Log("Droid destroyed by Black Hole!");
|
|||
|
Destroy(other.gameObject); // Détruit le droïde
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Debug.Log($"{other.gameObject.name} destroyed by Black Hole!");
|
|||
|
Destroy(other.gameObject); // Détruit tout autre objet
|
|||
|
}
|
|||
|
}
|
|||
|
}
|