From 98fdddb686fc9e0bad3729ceb3ecfc41a113e186 Mon Sep 17 00:00:00 2001 From: Christian Ohlsson Date: Wed, 16 Sep 2026 20:13:50 +0200 Subject: [PATCH] =?UTF-8?q?Satte=20r=C3=A4tt=20ordning=20p=C3=A5=20funktio?= =?UTF-8?q?nerna?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/PlayerController.cs | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 46a2185..bd3c9d5 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -19,13 +19,6 @@ public class BallController : MonoBehaviour { private Vector2 _moveInput; private PlayerControls _controls; - void Start() { - _ballSpeed = 5f; - _brakeForce = 0.3f; - _jumpForce = 300f; - _pickupLeft = GameObject.FindGameObjectsWithTag("PickUp").Length; - transform.position = new Vector3(0, 0.5f, 0); - } private void Awake() { _ball = GetComponent(); _controls = new PlayerControls(); @@ -45,10 +38,23 @@ public class BallController : MonoBehaviour { } }; } + + void Start() { + _ballSpeed = 5f; + _brakeForce = 0.3f; + _jumpForce = 300f; + _pickupLeft = GameObject.FindGameObjectsWithTag("PickUp").Length; + transform.position = new Vector3(0, 0.5f, 0); + } public void OnMove(InputAction.CallbackContext context) { _moveInput = context.ReadValue(); } + + void Update() { + CheckPlayerOut(); + UpdateGUI(); + } private void FixedUpdate() { Vector3 direction = @@ -61,22 +67,17 @@ public class BallController : MonoBehaviour { } } - void Update() { - CheckPlayerOut(); - UpdateGUI(); - } - - void UpdateGUI() { - _pickupLeftText.text = "Left: " + _pickupLeft.ToString(); - _timeSpentText.text = "Tid: " + Time.timeSinceLevelLoad.ToString("F1") + "s"; - } - void OnTriggerEnter(Collider other) { other.gameObject.SetActive(false); _pickupLeft--; if (_pickupLeft == 0) LevelDone(); } + + void UpdateGUI() { + _pickupLeftText.text = "Left: " + _pickupLeft.ToString(); + _timeSpentText.text = "Tid: " + Time.timeSinceLevelLoad.ToString("F1") + "s"; + } void LevelDone() { _pickupLeftText.gameObject.SetActive(false);