-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInputManager.cs
More file actions
43 lines (36 loc) · 1.02 KB
/
InputManager.cs
File metadata and controls
43 lines (36 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.EventSystems;
public class InputManager : MonoBehaviour
{
private PlayerInput playerInput;
public PlayerInput.OnFootActions onFoot;
private PlayerMotor motor;
private PlayerLook look;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Awake()
{
playerInput = new PlayerInput();
onFoot = playerInput.OnFoot;
motor = GetComponent<PlayerMotor>();
onFoot.Jump.performed += ctx => motor.Jump();
look = GetComponent<PlayerLook>();
}
private void OnEnable()
{
onFoot.Enable();
}
private void OnDisable()
{
onFoot.Disable();
}
// Update is called once per frame
void FixedUpdate()
{
motor.ProcessMove(onFoot.Movement.ReadValue<Vector2>());
}
private void LateUpdate()
{
look.ProcessLook(onFoot.Look.ReadValue<Vector2>());
}
}