im creating 2d endles runer like game and i need help i dont cnow how to load level when u reach sertyain amount of points can anyone help?
Well, you’d use this: Unity - Scripting API: SceneManagement.SceneManager.LoadScene
When you add to your score (after you do), check the score… then if it’s whatever value you’re looking to check, change scenes
so i need ad this on score manager ?
Yeah, if you have that already, add it in there.
Ty i try at home and let cnow does it worked
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ScoreManager : MonoBehaviour {
public Text scoreText;
public Text hiScoreText;
public float scoreCount;
public float hiScoreCount;
public float pointsPerSecond;
public bool scoreIncreasing;
// Use this for initialization
void Start () {
if (PlayerPrefs.HasKey (“highscore”) != null)
{
hiScoreCount = PlayerPrefs.GetFloat (“highscore”);
}
}
// Update is called once per frame
void Update () {
if (scoreIncreasing)
{
scoreCount += pointsPerSecond * Time.deltaTime;
}
if(scoreCount > hiScoreCount)
{
hiScoreCount = scoreCount;
PlayerPrefs.SetFloat (“highscore”, hiScoreCount);
}
scoreText.text = "score: " + Mathf.Round (scoreCount);
hiScoreText.text = “highscore :” + Mathf.Round (hiScoreCount);
}
public void AddScore(int pointsToAdd)
{
scoreCount += pointsToAdd;
}
}
where too put it ?
Please take a moment to look at this post, which shows you how to add code so it looks nicer in the forums: Using code tags properly - Unity Engine - Unity Discussions
You add it where you add to your score; You check if the score is 2,000 pts then change levels if it is (after updating your highscore if applicable).