Projet-IA-Madelaine/Scripts/GameObjectsScripts/FinishLineScript.cs

32 lines
761 B
C#
Raw Normal View History

2024-06-12 21:03:42 +02:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FinishLineScript : MonoBehaviour
{
private GameHandler _gameHandler;
// Start is called before the first frame update
void Awake()
{
_gameHandler = GameHandler.Instance;
_gameHandler.OnAttemptEnding += Destroy_OnAttemptEnding;
}
// Update is called once per frame
void Update()
{
gameObject.transform.position += new Vector3(-_gameHandler.FrameDistance, 0, 0);
}
public void Destroy_OnAttemptEnding(object sender, EventArgs args)
{
Destroy(gameObject);
}
private void OnDestroy()
{
GameHandler.Instance.OnAttemptEnding -= Destroy_OnAttemptEnding;
}
}