diff --git a/Assets/Scripts/Player/PlayerInput.cs b/Assets/Scripts/Player/PlayerInput.cs index 7721fc9..1641ec2 100644 --- a/Assets/Scripts/Player/PlayerInput.cs +++ b/Assets/Scripts/Player/PlayerInput.cs @@ -32,6 +32,9 @@ public class PlayerInput : MonoBehaviour private void Update() { + // check in update to switch if controller is connected/disconnected mid game + controller = Gamepad.all.ElementAtOrDefault(playerNumber); + if (controller != null) { movement.x = controller.leftStick.x.ReadValue(); @@ -47,18 +50,29 @@ public class PlayerInput : MonoBehaviour } else { + // wasd if (!useArrowKeys) { movement.x = Input.GetAxisRaw("bruh"); movement.y = Input.GetAxisRaw("bruh_v"); + + whipAttack = Input.GetKey(KeyCode.R); + + if (Input.GetKey(KeyCode.E)) ropeLengthShrinken?.Invoke(playerNumber); + if (Input.GetKey(KeyCode.Q)) ropeLengthExtend?.Invoke(playerNumber); } + // arrows keys else { movement.x = Input.GetAxisRaw("bruh2"); movement.y = Input.GetAxisRaw("bruh2_v"); + whipAttack = Input.GetKey(KeyCode.L); + + if (Input.GetKey(KeyCode.Comma)) ropeLengthShrinken?.Invoke(playerNumber); + if (Input.GetKey(KeyCode.Period)) ropeLengthExtend?.Invoke(playerNumber); + } - whipAttack = Input.GetKey(KeyCode.B); //Debug.Log($"player {playerNumber}: move {movement}"); } } diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index 9621f07..9996190 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -83,16 +83,14 @@ public class PlayerMovement : MonoBehaviour } } - + void OnCollisionStay2D(Collision2D collision) { if (collision.collider.gameObject.CompareTag("Enemy")) { // Other object is an enemy - if (whipAttack.IsBeingWhipped && rb.velocity.magnitude > attack.speedYouNeedToNotTakeDamageFromRammingOrSomtmh) { - // collision.collider.gameObject.GetComponent().TakeDamage(rb.velocity.magnitude * whipSmashDamageMult); - } else { - hp.TakeDamage(1f); - } + + hp.TakeDamage(1f); + } } }