Hello and thank you for attention, you are lovely.
My game: quick explanation
.
So I have scene where a space ship moves left and right, and it has to avoid asteroids, for the score I use Time .deltatime as if, this is how much my ship travelled without getting hit. ( but my ship is in one position the asteroids are spamming and moving at the ship).
I have a “menu”, “level1” and “End” scenes.
I have no idea how to send the currentScore to the “end” scene when the score count stopped.
I’ve tried set Float and get Float, but I’m just not there yet and its Time.Deltatime not just integer.
Please help me as it is the Last step in my game and I just want to get something finished in my Live.
I can get you more info if needed.
I need the score to be able to move to “end” scene and reset on a new game.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class Score : MonoBehaviour
{
[Header ("Component")]
public TextMeshProUGUI scoreText;
[Header(" Setting")]
public float currentScore;
bool stopScore = false;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (stopScore == false)
{
currentScore = currentScore = currentScore + 5 * Time.deltaTime;
}
SetScoreText();
}
public void SetScoreText()
{
scoreText.text = Mathf.Round(currentScore).ToString();
}
public void StartScore()
{
stopScore = false;
}
public void StopScore()
{
stopScore = true;
}
}
Keeping in mind that I am a beginner and fairly new to C#