Hi everyone,
I have a problem, I am trying to get the mouse movement using the Delta attribute but my method is not called.
Here is my action group:

My InputManager class:
public class InputManager : MonoBehaviour
{
[HideInInspector] public float MouseX;
[HideInInspector] public float MouseY;
[HideInInspector] public Vector2 moveValue;
public void OnMouseDelta(InputAction.CallbackContext context)
{
Debug.Log(context);
Debug.Log("Mouse movement");
}
public void OnMove(InputValue value)
{
moveValue = value.Get<Vector2>();
}
private void OnPause() { PauseManager.PM.TogglePause(); }
}
All the other methods work well but when (in play mode) I move my mouse nothing appen.
If anyone have an idea I thank him in advance and for the moment I keep searching.
How are you hooking up your callback methods to the Input Actions? Are you using the PlayerInput component, or something else?
There is an example from Unityâs Standard Assets with new Input system on the Github I think this is the link;
https://github.com/Unity-Technologies/Standard-Assets-Characters
public void OnMouseLook(InputAction.CallbackContext context)
{
var newInput = context.ReadValue<Vector2>();
m_UsingMouseInput = true;
//When using an InputGainAcceleration component, the look input processing should happen there.
if (m_UseInputGainAcceleration)
{
if (m_CameraInputGainAcceleration.hasProcessedMouseLookInput)
{
m_lookInput = Vector2.zero;
m_CameraInputGainAcceleration.hasProcessedMouseLookInput = false;
}
}
else
{
// If the mouse look input was already processed, then clear the value before accumulating again
if (m_HasProcessedMouseLookInput)
{
m_lookInput = Vector2.zero;
m_HasProcessedMouseLookInput = false;
}
}
m_lookInput += newInput;
}
Here is how it works in the action map
I thank you but I prefere to do it myself without using cinemachine if it is possible.
W
Who said anything about Cinemachine?
2 Likes
You donât have to use Cinemachine, you just need to understand how the Control map has mouseLook as a value Vector2, and how to implement that into your code using the above example or Unity assets example.
The link make a lot of reference about it.
And I have the same thing, my action map with MouseLook in Value : Vector2 bind to Mouse Delta but my method OnMouseLook still not called
I had an issue with capitalization on words, try change MouseDelta to mouseDelta in your control map. (set it to value, vector2)
Can you show the updated script, I guess you simplified it somehow, something like this (i havent tested this)
// Look input vector
Vector2 m_lookInput;
public void OnMouseDelta(InputAction.CallbackContext context)
{
var newInput = context.ReadValue<Vector2>();
m_lookInput += newInput;
}
Also note (If using the Standard Asset for instance) you would also need to reference;
StandardControls.IMovementActions (whatever yours is named)
using UnityEngine.InputSystem;
public abstract class CharacterInput : MonoBehaviour, StandardControls.IMovementActions
I donât know if I must laugh or cry I have an error for all input : âMissingMethodException: InputManager.OnMove Due to: Attempted to access a missing member.â I already have it by the past for the OnJump because I didnât used the IMovementActions interface and the use of InputValue instead of InputAction.CallbackContext resolve the errorâŚ
If you show your new script Iâll try and help. Are you saying you now made Jump work (but it didnât before?) and mouselook/mousedelta isnât working?
No all worked fine before exept mouselook/mousedelta but know nothing work
using UnityEngine;
using UnityEngine.InputSystem;
// StandardControls.IGameplayActions autmatically generated by unity based on the action map
// I have a PlayerInput element on my player linked to the action map
public class InputManager : MonoBehaviour, StandardControls.IGameplayActions
{
[HideInInspector] public float MouseX;
[HideInInspector] public float MouseY;
[HideInInspector] public Vector2 moveValue;
[HideInInspector] public Vector2 lookInput;
[HideInInspector] public bool jump = false;
public void OnMouseLook(InputAction.CallbackContext context)
{
Debug.Log("Mouse move");
lookInput += context.ReadValue<Vector2>();
}
public void OnJump(InputAction.CallbackContext context)
{
if(context.started) { jump = true; }
else if(context.canceled) { jump = false; }
}
public void OnMove(InputAction.CallbackContext context)
{
moveValue = context.ReadValue<Vector2>();
}
public void OnPause(InputAction.CallbackContext context)
{
PauseManager.PM.TogglePause();
}
}
Ok and the control map is now updated to mouseLook ^ value and vector 2 yeah?
Yes since the first time you said it
Ok so when you update your control map, it will make a CS file; just make sure itâs updated;
further down this automatically generated script will be this;

Just make sure IMovementActions here is the correct reference you will use (whatever yours is named âIGameplayActionsâ)
Back to your script
try
using UnityEngine;
using UnityEngine.InputSystem;
// StandardControls.IGameplayActions autmatically generated by unity based on the action map
// I have a PlayerInput element on my player linked to the action map
public class InputManager : MonoBehaviour, StandardControls.IGameplayActions
{
[HideInInspector] public float MouseX;
[HideInInspector] public float MouseY;
[HideInInspector] public Vector2 moveValue;
[HideInInspector] public Vector2 lookInput;
[HideInInspector] public bool jump = false;
public void OnMouseLook(InputAction.CallbackContext context)
{
var newInput = context.ReadValue<Vector2>();
lookInput += newInput;
Debug.Log("Mouse move");
}
public void OnJump(InputAction.CallbackContext context)
{
if(context.started) { jump = true; }
else if(context.canceled) { jump = false; }
}
public void OnMove(InputAction.CallbackContext context)
{
moveValue = context.ReadValue<Vector2>();
}
public void OnPause(InputAction.CallbackContext context)
{
PauseManager.PM.TogglePause();
}
}

I just looked at mine (but i used the standard asset and changed it) and I donât have a Player Input on my player lol, but it works without it
Here is how my map looks (title is StandardControls)

So I try again later I have an appointement but a big thank you for your help.
I removed the PlayerInput component and yes I have no more errors but no more action neither. Nothing, no jump, no move, no pause, etcâŚ