Seperated keyboard movement

This commit is contained in:
BOT Alex 2024-02-03 21:35:06 +01:00
parent 1257b134d3
commit 3ad9042702
5 changed files with 64 additions and 15 deletions

View File

@ -27,7 +27,7 @@ public class PlayerAnimationHandler : MonoBehaviour
} }
prevPos = transform.position; prevPos = transform.position;
} }
public void Idle() public void Idle()
{ {

View File

@ -17,6 +17,8 @@ public class PlayerInput : MonoBehaviour
public event Action<int> ropeLengthShrinken; public event Action<int> ropeLengthShrinken;
public event Action<int> ropeLengthExtend; public event Action<int> ropeLengthExtend;
public bool useArrowKeys = false;
public int PlayerNum => playerNumber; public int PlayerNum => playerNumber;
private void Start() private void Start()
@ -45,11 +47,19 @@ public class PlayerInput : MonoBehaviour
} }
else else
{ {
movement.x = Input.GetAxisRaw("Horizontal"); if (!useArrowKeys)
movement.y = Input.GetAxisRaw("Vertical"); {
movement.x = Input.GetAxisRaw("bruh");
movement.y = Input.GetAxisRaw("bruh_v");
}
else
{
movement.x = Input.GetAxisRaw("bruh2");
movement.y = Input.GetAxisRaw("bruh2_v");
}
whipAttack = Input.GetKey(KeyCode.B); whipAttack = Input.GetKey(KeyCode.B);
//Debug.Log($"player {playerNumber}: move {movement}");
} }
//Debug.Log($"player {playerNumber}: move {movement}");
} }
} }

View File

@ -35,6 +35,11 @@ public class PlayerMovement : MonoBehaviour
rb = GetComponent<Rigidbody2D>(); rb = GetComponent<Rigidbody2D>();
playerInput = GetComponent<PlayerInput>(); playerInput = GetComponent<PlayerInput>();
if (gameObject.name == "Player2")
{
playerInput.useArrowKeys = true;
}
StartCoroutine(ToggleWithDelay()); StartCoroutine(ToggleWithDelay());
} }

View File

@ -11,4 +11,5 @@ EditorBuildSettings:
- enabled: 1 - enabled: 1
path: Assets/Scenes/GameScene.unity path: Assets/Scenes/GameScene.unity
guid: 0400e5e5779425c40ba3164b1e0b5b59 guid: 0400e5e5779425c40ba3164b1e0b5b59
m_configObjects: {} m_configObjects:
com.unity.input.settings: {fileID: 11400000, guid: de04e34f85a966e4da851d9b3d804fa1, type: 2}

View File

@ -150,11 +150,11 @@ InputManager:
axis: 2 axis: 2
joyNum: 0 joyNum: 0
- serializedVersion: 3 - serializedVersion: 3
m_Name: Horizontal m_Name: bruh
descriptiveName: descriptiveName:
descriptiveNegativeName: descriptiveNegativeName:
negativeButton: negativeButton: a
positiveButton: positiveButton: d
altNegativeButton: altNegativeButton:
altPositiveButton: altPositiveButton:
gravity: 0 gravity: 0
@ -162,11 +162,11 @@ InputManager:
sensitivity: 1 sensitivity: 1
snap: 0 snap: 0
invert: 0 invert: 0
type: 2 type: 0
axis: 0 axis: 15
joyNum: 0 joyNum: 6
- serializedVersion: 3 - serializedVersion: 3
m_Name: Vertical m_Name: bruh_v
descriptiveName: descriptiveName:
descriptiveNegativeName: descriptiveNegativeName:
negativeButton: negativeButton:
@ -178,9 +178,9 @@ InputManager:
sensitivity: 1 sensitivity: 1
snap: 0 snap: 0
invert: 1 invert: 1
type: 2 type: 0
axis: 1 axis: 15
joyNum: 0 joyNum: 8
- serializedVersion: 3 - serializedVersion: 3
m_Name: Fire1 m_Name: Fire1
descriptiveName: descriptiveName:
@ -485,3 +485,36 @@ InputManager:
type: 2 type: 2
axis: 5 axis: 5
joyNum: 0 joyNum: 0
- serializedVersion: 3
m_Name: bruh2
descriptiveName:
descriptiveNegativeName:
negativeButton: left
positiveButton: right
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 27
joyNum: 10
- serializedVersion: 3
m_Name: bruh2_v
descriptiveName:
descriptiveNegativeName:
negativeButton: down
positiveButton: up
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 5
joyNum: 8
m_UsePhysicalKeys: 1