I am learning from some old tutorials that do not use the player input component, but as I am trying for now I have no luck using only the generated C# scripting without using the Player Input Component.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class Player_Input : MonoBehaviour
{
public GameObject unitSelected;
public Controls controls;
private void Awake()
{
controls = new Controls();
}
private void OnEnable()
{
controls.Enable();
controls.General.Attack.performed += ShootButton;
controls.General.Move.performed += MoveButton;
}
private void OnDisable()
{
controls.General.Attack.performed -= ShootButton;
controls.General.Move.performed -= MoveButton;
controls.Disable();
}
public void ShootButton(InputAction.CallbackContext context)
{
if (context.started && !context.performed)
{
//Shoot Here
Debug.Log("Shoot");
}
}
public void MoveButton(InputAction.CallbackContext context)
{
if (context.started && !context.performed)
{
//Movement here
unitSelected.GetComponent<Movement_Controller>().Move();
}
}
}