Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

I'm not sure what is wrong with my script

$
0
0
This is probably some noob mistake, but I have looked over this script a hundred times and I can't see why it doesn't work. It is supposed to record the time between mouse clicks clicking on a dot that moves randomly around the screen and displaying that time in a separate scene. For now I just want to display the time in the debug log and make sure that's working, and also the scene changing process, neither of which work right now. I'm a beginner and any help is appreciated, thanks. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class Timer : MonoBehaviour { private List timers; private float lastClickTime = -1; private void Start() { timers = new System.Collections.Generic.List(); } private void OnTriggerEnter2D (Collider2D other) { timers.Add(lastClickTime > 0 ? Time.time - lastClickTime : Time.time); if (timers.Count == 9) { PlayerPrefs.SetFloat("RTime", 0f + Time.time); Debug.Log (PlayerPrefs.GetFloat("RTime")); SceneManager.LoadScene("GamePanel", LoadSceneMode.Single); } } }

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>