Chataigne/Assets/Script/Checkpoint.cs
Djalim Simaila 70ea99a9ce CHANGEMENTS
SlowDown
Respawn & Checkpoint
Barre de vie (bug ; vie ne -2)
+ ajouts d'assets
2023-05-07 19:46:55 +02:00

29 lines
582 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Checkpoint : MonoBehaviour
{
[SerializeField] public Vector2 spawnCoords;
void Start()
{
Rigidbody2D rb = GetComponent<Rigidbody2D>();
spawnCoords = rb.position;
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.CompareTag("Joueur"))
{
Player player = collision.gameObject.GetComponent<Player>();
player.setSpawnPoint(spawnCoords);
}
}
}