This is very weird since when i delete the C# script everything works but the input actions are completly different for example i changed the sprint key from Control to Shift and it still thinks its Control here is a screenshot of The input action and it clearly shows shift. I’m just confused to why it works without having a C# class generated
Here is the compile errors i get when generating a C# class for it
This is the only way i am interacting with the input system.
using UnityEngine;
using UnityEngine.InputSystem;
public class Controls : MonoBehaviour
{
private PlayerControl input;
private Movement movement;
public GunHandler gunHandler;
[Header("Axis")]
public Vector2 movementVector = Vector2.zero;
public Vector2 lookVector = Vector2.zero;
[Header("Detection")]
public bool isInteracting = false;
public bool isSprinting = false;
public bool isCrawling = false;
public bool isAiming = false;
private void Awake()
{
input = new PlayerControl();
movement = GetComponent<Movement>();
if (input == null || movement == null)
{
Debug.LogError("Input or Movement component is missing.");
}
}
private void OnEnable()
{
input.Enable();
input.Player.Movement.performed += ctx => movementVector = ctx.ReadValue<Vector2>();
input.Player.Movement.canceled += _ => movementVector = Vector2.zero;
input.Player.Crawl.performed += ToggleCrouch;
input.Player.Look.performed += ctx => lookVector = ctx.ReadValue<Vector2>();
input.Player.Look.canceled += _ => lookVector = Vector2.zero;
input.Player.Interact.performed += _ => isInteracting = true;
input.Player.Interact.canceled += _ => isInteracting = false;
input.Player.Sprint.performed += _ => isSprinting = true;
input.Player.Sprint.canceled += _ => isSprinting = false;
input.Player.Jump.performed += _ => movement.Jump();
input.Player.Aim.performed += _ => isAiming = true;
input.Player.Aim.canceled += _ => isAiming = false;
input.Player.Fire.performed += _ => gunHandler.Fire();
}
private void ToggleCrouch(InputAction.CallbackContext value)
{
isCrawling = !isCrawling;
}
private void OnDisable()
{
input.Disable();
}
private void OnDestroy()
{
input.Dispose();
}
// Other methods and properties can be added as needed
}