diff --git a/Assets/Scripts/BallController.cs b/Assets/Scripts/BallController.cs index 712649b..4028b61 100644 --- a/Assets/Scripts/BallController.cs +++ b/Assets/Scripts/BallController.cs @@ -1,22 +1,21 @@ -using Unity.VisualScripting; using UnityEngine; using UnityEngine.InputSystem; public class BallController : MonoBehaviour { - private float ballSpeed; - private float brakeForce; - private float jumpForce; - private Rigidbody rb; + float _ballSpeed; + float _brakeForce; + float _jumpForce; + Rigidbody _ball; float outOfBounds = -1.8f; - public void Start() { - rb = GetComponent(); - ballSpeed = 3f; - brakeForce = 0.3f; - jumpForce = 14f; + void Start() { + _ball = GetComponent(); + _ballSpeed = 3f; + _brakeForce = 0.3f; + _jumpForce = 14f; } - private void Update() { + void Update() { KeyHandler(); CheckPlayerOut(); } @@ -28,25 +27,24 @@ public class BallController : MonoBehaviour { } } - public void KeyHandler() { + void KeyHandler() { if (Keyboard.current.wKey.isPressed) { - rb.AddForce(Vector3.forward * ballSpeed); + _ball.AddForce(Vector3.forward * _ballSpeed); } else if (Keyboard.current.sKey.isPressed) { - rb.AddForce(Vector3.back * ballSpeed); + _ball.AddForce(Vector3.back * _ballSpeed); } else if (Keyboard.current.dKey.isPressed) { - rb.AddForce(Vector3.right * ballSpeed); + _ball.AddForce(Vector3.right * _ballSpeed); } else if (Keyboard.current.aKey.isPressed) { - rb.AddForce(Vector3.left * ballSpeed); + _ball.AddForce(Vector3.left * _ballSpeed); } if (Keyboard.current.spaceKey.isPressed && transform.position.y < 1) { - Debug.Log("KrossKross will make you..."); - rb.AddForce(Vector3.up * jumpForce); + _ball.AddForce(Vector3.up * _jumpForce); } else { - rb.AddForce(-rb.linearVelocity * brakeForce); + _ball.AddForce(-_ball.linearVelocity * _brakeForce); } } } \ No newline at end of file