I have put 2 buttons on canvas and both has got on-screen button, which which is supposed to act as gamepad left stick/ left and right. So in Input Actions, I set gamepad left stick/left and right bindings, and player object has been set a player input which has call back context of gamepad, which should call a method, which prints “Touch Fired”, atleast that’s how I want it to work. But when I click those buttons while game is running, nothings prints in the console. But the keyboard actions that i have set works correctly. So i tried setting up a dummy onscreen stick, and in run mode im able to move the stick but that also isnt firing the OnTouch method which is supposed to print “Touch Fired” in console.
PlayerControls.cs :
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerControl : MonoBehaviour
{
public Rigidbody rb;
public float forwardForce = 2000f, horForce = 2000f;
private float inputMovement = 0, rawInput;
[SerializeField] private PlayerInput playerInput;
public void OnMovement(InputAction.CallbackContext value)
{
Debug.Log("Keyboard Fired");
inputMovement = value.ReadValue<float>();
}
public void OnTouch(InputAction.CallbackContext value)
{
Debug.Log("Touch Fired");
}
void FixedUpdate()
{
rb.AddForce(inputMovement * horForce * Time.deltaTime, 0, forwardForce * Time.deltaTime);
}
}
Here is my Input Action and button setups, followed by player settings