using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MP
{
public class inputHandler : MonoBehaviour
{
public float horizontal;
public float vertical;
public float moveAmount;
public float mouseX;
public float mouseY;
PlayerControls inputActions;
Vector2 movementInput;
Vector2 cameraInput;
public void OnEnable()
{
if (inputActions == null)
{
inputActions = new PlayerControls;
inputActions.PlayerMovement.Movement.performed += inputActions => movementInput = inputActions.ReadValue<Vector2>();
inputActions.PlayerMovement.Camera.performed += i => cameraInput = i.ReadValue<Vector2>();
}
inputActions.Enable();
}
private void OnDisable()
{
inputActions.Disable();
}
public void TickInput(float delta)
{
MoveInput(delta);
}
private void MoveInput(float delta)
{
horizontal = movementInput.x;
vertical = movementInput.y;
moveAmount = Mathf.Clamp01(Mathf.Abs(horizontal) + Mathf.Abs(vertical));
mouseX = cameraInput.x;
mouseY = cameraInput.y;
}
}
}
inputActions = new PlayerControls;
==>
inputActions = new PlayerControls( );
// | | |
// A new expression | |
// | requires ( )
// |
// after type
1 Like
thank you!!