Keyboard controls:
Player 1: extend: Q shrink: E Swing: R Player 2: extend: . shrink: , swing: L
This commit is contained in:
parent
98421cb784
commit
f582ea491a
|
@ -32,6 +32,9 @@ public class PlayerInput : MonoBehaviour
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
|
// check in update to switch if controller is connected/disconnected mid game
|
||||||
|
controller = Gamepad.all.ElementAtOrDefault(playerNumber);
|
||||||
|
|
||||||
if (controller != null)
|
if (controller != null)
|
||||||
{
|
{
|
||||||
movement.x = controller.leftStick.x.ReadValue();
|
movement.x = controller.leftStick.x.ReadValue();
|
||||||
|
@ -47,18 +50,29 @@ public class PlayerInput : MonoBehaviour
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// wasd
|
||||||
if (!useArrowKeys)
|
if (!useArrowKeys)
|
||||||
{
|
{
|
||||||
movement.x = Input.GetAxisRaw("bruh");
|
movement.x = Input.GetAxisRaw("bruh");
|
||||||
movement.y = Input.GetAxisRaw("bruh_v");
|
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
|
else
|
||||||
{
|
{
|
||||||
movement.x = Input.GetAxisRaw("bruh2");
|
movement.x = Input.GetAxisRaw("bruh2");
|
||||||
movement.y = Input.GetAxisRaw("bruh2_v");
|
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}");
|
//Debug.Log($"player {playerNumber}: move {movement}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,16 +83,14 @@ public class PlayerMovement : MonoBehaviour
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCollisionStay2D(Collision2D collision)
|
void OnCollisionStay2D(Collision2D collision)
|
||||||
{
|
{
|
||||||
if (collision.collider.gameObject.CompareTag("Enemy"))
|
if (collision.collider.gameObject.CompareTag("Enemy"))
|
||||||
{ // Other object is an enemy
|
{ // Other object is an enemy
|
||||||
if (whipAttack.IsBeingWhipped && rb.velocity.magnitude > attack.speedYouNeedToNotTakeDamageFromRammingOrSomtmh) {
|
|
||||||
// collision.collider.gameObject.GetComponent<HealthComponent>().TakeDamage(rb.velocity.magnitude * whipSmashDamageMult);
|
hp.TakeDamage(1f);
|
||||||
} else {
|
|
||||||
hp.TakeDamage(1f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue