Scriptum/Assets/Scripts/RespawnScript.cs
KrolMel be7009c578 Health Fixed
After respawn health fixed. Also added new map.
2022-11-05 20:25:40 +01:00

25 lines
696 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 FloatValue maxHealth;
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;
PlayerPrefs.SetFloat("health", 10.0f);
PlayerPrefs.SetFloat("health-S", 10.0f);
}
}