Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- public class PlayerControllerNew : MonoBehaviour {
- public int restartLevel;
- public int changeSpeed;
- public float speed;
- private bool paused;
- private bool newHighscorebool;
- private Rigidbody rb;
- public Text ScoreText;
- public Text ScoreNum;
- private float Timer = 0f;
- private float Score;
- public AudioSource newHighscoreWin;
- void Start()
- {
- rb = GetComponent<Rigidbody> ();
- Cursor.visible = (false);
- TimerText.text = "Timer: ";
- ScoreText.text = "Score: ";
- DeathCanvas.enabled = false;
- newHighscorebool = false;
- }
- void Update ()
- {
- //gets the value of transform.position.z of the ball and divides it by 2 to give the score a value
- Score = (int)transform.position.z / 2;
- Timer = Timer + Time.deltaTime;
- if (Score > PlayerPrefs.GetFloat ("Highscore")) {
- newHighscorebool = true;
- }
- }
- void FixedUpdate ()
- {
- //player movement code
- float moveHorizontal = Input.GetAxis ("Horizontal");
- float moveVertical = Input.GetAxis ("Vertical");
- Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
- rb.AddForce (movement * speed);
- if (newHighscorebool == true) {
- newHighscoreWin.Play();
- Debug.Log ("newhs");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement