New input system, was following a blog post tutorial. But for me the OnJump method is not called at all, I don’t see the Debug Log “OnJump”. Any thoughts?
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class InputManager : MonoBehaviour
{
private void Awake()
{
GetComponent<PlayerInput>().onActionTriggered += OnJump;
GetComponent<PlayerInput>().onControlsChanged += OnDeviceChanged;
}
private void Start()
{
BroadcastMessage("receiveMsg", "test", SendMessageOptions.DontRequireReceiver);
}
private void OnJump(InputAction.CallbackContext context)
{
Debug.Log("OnJump");
if (context.action.name != "Jump") return;
Debug.Log("Jump");
GetComponent<Rigidbody>().AddForce(Vector3.up * 50);
}
private void OnDeviceChanged(PlayerInput obj)
{
Debug.Log("Device now is: " + obj.currentControlScheme);
}
}