Scriptum/Assets/Scripts/RespawnScript.cs
KrolMel 2e648df55e Fixed player position
Added automatic player appearance, fixed teleports
2022-10-01 15:39:24 +02:00

23 lines
568 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class RespawnScript : MonoBehaviour
{
private string currentScene;
public GameObject mainCh;
public void RespawnOnCurrentScene()
{
mainCh = GameObject.FindGameObjectWithTag("Player");
Scene scene = SceneManager.GetActiveScene();
currentScene = scene.name;
SceneManager.LoadScene(currentScene);
Player player = mainCh.GetComponent<Player>();
player.currentHealth = 10.0f;
}
}