Hello,
Are those two compatible or will they be in future release? For now, I’m using Old input system for Input Axis Name parameter in the CM Free Look cam and the new system in my character controller. But I was wondering if CM will support the new input system later or vice-versa.
Thanks.
This worked for me:
I bet you did I’m having headaches too. Many thanks for your help, I’m going to test it tonight!
Hello @Gandarufu , again thanks for the help. Just to let you and others know some points.
- As Cinemachine still needs the old input system, don’t forget to check if you have “Mouse X” and “Mouse Y” inputs in the Input list ; or if you choose to have custom names (in my case it’s “CamControlX” and “CamControlY”), don’t forget to create them in the old Input Manager list as you’ll get errors. I’m hoping that won’t be mandatory later.
System.ArgumentException: Input Axis CamControlX is not setup.
To change the input settings use: Edit → Settings → Input at (wrapper managed-to-native) UnityEngine.Input.GetAxis(string)
- Also, I modified a little bit your code, LookDelta not being updated when moving my gamepad rightstick.
using UnityEngine;
using Cinemachine;
public class InputCameraController : MonoBehaviour
{
private PrototypeInputSystem inputSystem;
private Vector2 LookCamera; // your LookDelta
public float deadZoneX = 0.2f;
private void Awake()
{
inputSystem = new PrototypeInputSystem();
inputSystem.PlayerGameplay.CameraControl.performed += ctx => LookCamera = ctx.ReadValue<Vector2>().normalized;
inputSystem.PlayerGameplay.CameraControl.performed += ctx => GetInput();
}
private void GetInput()
{
CinemachineCore.GetInputAxis = GetAxisCustom;
}
public float GetAxisCustom(string axisName)
{
// LookCamera.Normalize();
if (axisName == "CamControlX")
{
if (LookCamera.x > deadZoneX || LookCamera.x < -deadZoneX) // To stabilise Cam and prevent it from rotating when LookCamera.x value is between deadZoneX and - deadZoneX
{
return LookCamera.x;
}
}
else if (axisName == "CamControlY")
{
return LookCamera.y;
}
return 0;
}
private void OnEnable()
{
inputSystem.PlayerGameplay.Enable();
}
private void OnDisable()
{
inputSystem.PlayerGameplay.Disable();
}
}
And it’s working beautifully!
Hi @MlleBun , Today I just learned new Input System and Cinemachine. I try to make the Action in Editor dialog, but I got issue when it ran.
Please help me to check my setup and figerout the problem.
Best regards,
Hi @northman , are you having errors or is the script working but you are not having the desired behaviour on your mouse control?
Ok so I did the thing all I’m trying to do is set up the mouse to be used by CM
It’s not exactly moving but there are no errors in the code. I’m not sure if I should add it as a component to the camera? Should I use Unity Engine.Inputcontroller? I am at a stalemate.
using UnityEngine;
using Cinemachine;
public class FreeLookUserInput : MonoBehaviour
{
private PlayerControls playerControls;
private Vector2 lookCamera;
public float deadZoneX = 0.2f;
// Start is called before the first frame update
private void Awake()
{
playerControls = new PlayerControls();
playerControls.Player.Look.performed += ctx => lookCamera = ctx.ReadValue<Vector2>().normalized;
playerControls.Player.Look.performed += ctx => GetInput();
}
private void GetInput()
{
CinemachineCore.GetInputAxis = GetAxisCustom;
}
public float GetAxisCustom(string axisName)
{
//LookCamer.Normalized
if(axisName == "Mouse X")
{
if(lookCamera.x > deadZoneX || lookCamera.x < -deadZoneX)
{
return lookCamera.x;
}
}
else if (axisName == "Mouse Y")
{
return lookCamera.y;
}
return 0;
}
private void OnEnable()
{
playerControls.Player.Enable();
}
private void OnDisable()
{
playerControls.Player.Disable();
}
}
Hi,
I’ve managed the problem in this way:
public class SwitchCamera : MonoBehaviour
{
public GameObject cinemachine;
private CinemachineFreeLook freeLook;
void Start()
{
freeLook = cinemachine.GetComponent<CinemachineFreeLook>();
}
public void Look(InputAction.CallbackContext context)
{
freeLook.m_XAxis.m_InputAxisValue = context.ReadValue<Vector2>().x;
freeLook.m_YAxis.m_InputAxisValue = context.ReadValue<Vector2>().y;
}
}
-
Assigned my cinemachine FreeLook Camera to “cinemachine” in the Editor .
-
Left blank the fields “Input Axis Name” both in Axis Control > Y Axis and Axis Control> X Axis
-
Assigned the SwitchCamera.Look function to Events> Player > Look (Callback Context) in the Player Input Component, according to Quick start guide | Input System | 1.0.2
@Gregoryl Any authoritative advice on this? And are there any plans to free Cinemachine from the clutches of the old input system?
@transat We are working on better support for the New Input System
Hello, I’m working on my project and I have this problem, but I tried this solution and it’s fine, I haven’t error but now when I move my mouse, the freelook cam turn but don’t stop, even when I release my mouse. Someone has met this problem ?
Hi
Hi @Beshop , could you post a screenshot of your Input actions to see your setup? Thanks
Hey @Beshop , I think I was having the same problem you were, where the camera would continue rotating in a direction even after you stopped giving input. I managed to find a solution. Along side where the inputs are assigned in the code’s Awake function add this:
playerControls.Player.Look.canceled += ctx => LookCamera = Vector2.zero;
This makes it so when you stop giving input, the LookCamera Vector2 will reset its value and stop moving rather than retain the last value it had and keep moving the camera.
Hope this helps!
Hi everyone, got the same issue with the mouse, but I could solve it just by changing the binding with no change in the script shared above :
Hope it solves your problem!
I had an issue with this as well last month, I managed to make it work and did a small article about it if anyone is still interested: Cinemachine with the New Input System | by Samuel Montambault | Medium
trying to follow a tutorial on youtube about creating a third person controller, two hours later I’m trying to find a fix for cinemachine and input package. unity learning workflow never let me down.
Agree re the Unity learning workflow. But FYI, Cinemachine 2.6 now has a component you can attach to your virtual cameras to fix the issue. If you spend another hour on the Unity blog and forum you will find info about it. Good luck!
On a less cynical note, documentation aside, the Cinemachine team is actually one of the best at Unity. They do quality work and are quite responsive on the forum so no doubt you will get the answers you are looking for.
What about helping a fellow forum member and just tell me how to do this instead
From memory you add a component called input axis provider (or something like that) to your virtual camera. I’m not in front of my project right now so can’t be more specific.
Add a CinemachineInputProvider component.