Batman
This commit is contained in:
39
Assets/Player/PlayerController.cs
Normal file
39
Assets/Player/PlayerController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PlayerController : BasicCharacter {
|
||||
|
||||
[SerializeField] private InputActionAsset _inputAsset;
|
||||
[SerializeField] private InputActionReference _movementAction;
|
||||
|
||||
protected override void Awake() {
|
||||
base.Awake();
|
||||
if (_inputAsset == null) return;
|
||||
}
|
||||
|
||||
private void OnEnable() {
|
||||
if (_inputAsset == null) return;
|
||||
_inputAsset.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable() {
|
||||
if (_inputAsset == null) return;
|
||||
_inputAsset.Disable();
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
HandleMovementInput();
|
||||
}
|
||||
|
||||
void HandleMovementInput() {
|
||||
if (_movementBehaviour == null ||
|
||||
_movementAction == null)
|
||||
return;
|
||||
//movement
|
||||
float movementInput = _movementAction.action.ReadValue<float>();
|
||||
Vector3 movement = movementInput * Vector3.right;
|
||||
_movementBehaviour.DesiredMovementDirection = movement;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user