Använder nya Input-systemet
This commit is contained in:
@@ -20,14 +20,14 @@ public class BallController : MonoBehaviour {
|
|||||||
private PlayerControls _controls;
|
private PlayerControls _controls;
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
_ball = GetComponent<Rigidbody>();
|
_ballSpeed = 5f;
|
||||||
_ballSpeed = 3f;
|
|
||||||
_brakeForce = 0.3f;
|
_brakeForce = 0.3f;
|
||||||
_jumpForce = 14f;
|
_jumpForce = 300f;
|
||||||
_pickupLeft = GameObject.FindGameObjectsWithTag("PickUp").Length;
|
_pickupLeft = GameObject.FindGameObjectsWithTag("PickUp").Length;
|
||||||
transform.position = new Vector3(0, 0.5f, 0);
|
transform.position = new Vector3(0, 0.5f, 0);
|
||||||
}
|
}
|
||||||
private void Awake() {
|
private void Awake() {
|
||||||
|
_ball = GetComponent<Rigidbody>();
|
||||||
_controls = new PlayerControls();
|
_controls = new PlayerControls();
|
||||||
}
|
}
|
||||||
private void OnEnable() {
|
private void OnEnable() {
|
||||||
@@ -40,8 +40,7 @@ public class BallController : MonoBehaviour {
|
|||||||
_moveInput = Vector2.zero;
|
_moveInput = Vector2.zero;
|
||||||
|
|
||||||
_controls.Player.Jump.performed += ctx => {
|
_controls.Player.Jump.performed += ctx => {
|
||||||
Debug.Log("SPACE TRYCKT");
|
if (transform.position.y < 1.0f) {
|
||||||
if (transform.position.y < 1) {
|
|
||||||
_ball.AddForce(Vector3.up * _jumpForce);
|
_ball.AddForce(Vector3.up * _jumpForce);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -63,7 +62,6 @@ public class BallController : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
//KeyHandler();
|
|
||||||
CheckPlayerOut();
|
CheckPlayerOut();
|
||||||
UpdateGUI();
|
UpdateGUI();
|
||||||
}
|
}
|
||||||
@@ -95,27 +93,4 @@ public class BallController : MonoBehaviour {
|
|||||||
transform.rotation = Quaternion.Euler(0, 0, 0);
|
transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void KeyHandler() {
|
|
||||||
if (Keyboard.current.wKey.isPressed) {
|
|
||||||
_ball.AddForce(Vector3.forward * _ballSpeed);
|
|
||||||
}
|
|
||||||
else if (Keyboard.current.sKey.isPressed) {
|
|
||||||
_ball.AddForce(Vector3.back * _ballSpeed);
|
|
||||||
}
|
|
||||||
else if (Keyboard.current.dKey.isPressed) {
|
|
||||||
_ball.AddForce(Vector3.right * _ballSpeed);
|
|
||||||
}
|
|
||||||
else if (Keyboard.current.aKey.isPressed) {
|
|
||||||
_ball.AddForce(Vector3.left * _ballSpeed);
|
|
||||||
}
|
|
||||||
if (Keyboard.current.spaceKey.isPressed && transform.position.y < 1) {
|
|
||||||
_ball.AddForce(Vector3.up * _jumpForce);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_ball.AddForce(-_ball.linearVelocity * _brakeForce);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user