I need help to add points to my game...,I need help to add points on my game
i have made a script added to a terrain block that detects when a player falls on it. im trying to make it add 1 point on the ui everytime it happens but cant seem to figure it out:( i have tried alot of things but none of it seemed to work, and i wanna know how i save my point variable after it reloads the scene.
Pls help me i would appreciate it alot:)
Her is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class DieRestart : MonoBehaviour
{
static public int gemtePoint;
static public int point = 0;
public Text blåPoint;
[SerializeField]
string strTag;
void start()
{
point = gemtePoint;
}
void bPoint()
{
point = gemtePoint;
}
public void OnCollisionEnter(Collision collision)
{
if(collision.collider.tag == strTag)
point++;
blåPoint.text =("Point: " + point);
SendMessage("bPoint");
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613031305im_/https://answers.unity.com/themes/thub/images/avi.jpg)