When a player collides with any thing it should die but when the player hit any thing on my phone it doent die but it dies on pc.
heres my script:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.IO;
public class playerDead : MonoBehaviour
{
public Text points;
public int savedPoints;
public string highestPoints;
public bool isdead;
public GameObject deadScreen;
public Text highscoreTextObject;
playerMovement playerMovement;
void Start()
{
playerMovement = GameObject.Find("scriptHandler").GetComponent<playerMovement>();
points.enabled = true;
deadScreen.SetActive(false);
}
void Update()
{
highestPoints = File.ReadAllText("score.txt");
if (isdead)
{
savedPoints = int.Parse(points.text);
if (savedPoints >= int.Parse (highestPoints))
{
highestPoints = savedPoints.ToString();
System.IO.File.WriteAllText("score.txt", highestPoints.ToString());
Debug.Log("write");
}
highscoreTextObject.text = File.ReadAllText("score.txt");
Time.timeScale = 0;
points.enabled = false;
deadScreen.SetActive(true);
playerMovement.enabled = false;
}
}
void OnCollisionEnter(Collision collision)
{
isdead = true;
}
public void ContinuButton()
{
isdead = false;
Time.timeScale = 1;
SceneManager.LoadScene("mainMenu");
}
public void Retry()
{
isdead = false;
SceneManager.LoadScene("game");
}
}