Input System Integration - Demo Not Working

Vesuvian

New member
Hello!

I am unable to get the Ultimate Character Controller to move at all with the new Unity Input System.

Unity 2021.2.4f1 Personal
Input System 1.1.1
Ultimate Character Controller 2.4.4

I am using the latest InputSystem.unitypackage from the Opsive integrations page.
I have added all of the packages to a fresh project.
Project Settings -> Player -> Active Input Handling is set to Input System Package (New).
I have added Unity.InputSystem as an asmdef reference to Opsive.Shared to fix errors as a result of the CharacterInput.cs being generated in the wrong directory.

When I run the demo scene included with the Opsive integration (NOT the UCC demo scene) I am unable to move the character at all.

When I debug the UnityInputSystem and CharacterInput components it looks like the Raw Look Vector and Current Look Vector never change from 0. Step-by-step debugging confirms the PlayerInput component is polling the correct InputAction every update.

Is there something simple I'm missing here?
 
Hmm, if the look vector doesn't change then it doesn't sound like the input system is detecting your input. Maybe you need to add a new mapping for the type of input that you are using?
 
Hi Justin

I should have clarified, I'm using mouse and keyboard for testing.

When I look at the device in the input debugger window I can see my inputs are being detected by Unity.
 
In a new script if you do a m_PlayerInput.GetInput does the correct value return?
 
m_PlayerInput is the PlayerInput component. Your script would look something like:

Code:
        public PlayerInput m_PlayerInput;
       
        private void Update()
        {
            Debug.Log(m_PlayerInput.GetAxis("Mouse X"));
        }
 
Your example code, when attached to Nolan in the demo scene, is printing 0 to the console every update.

I have modified UnityInputSystem.cs to rule out the case where the action may not be found:

C#:
        protected override float GetAxisInternal(string name)
        {
            var action = GetActionByName(name);
            if (action != null) {
                return action.ReadValue<float>();
            }

            throw new KeyNotFoundException();

            return 0.0f;
        }

When I step into InputAction.ReadValue I can see the input action phase is "waiting", so the method returns the default value.
 
Interesting, I haven't dug deep enough into the new input system to know what a waiting phase is. I would try posting this on the regular Unity forum as it doesn't look related to the character controller.
 
I have updated the test script, note I am no longer using the Opsive PlayerInput but the Unity PlayerInput component:

C#:
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;


public class TestPlayerInput : MonoBehaviour
{
    private PlayerInput m_PlayerInput;
    
    void Start()
    {
        m_PlayerInput = GetComponent<PlayerInput>();
    }
    
    void Update()
    {
        InputAction inputAction = m_PlayerInput.currentActionMap?.FindAction("Mouse X");
        if (inputAction == null)
            throw new KeyNotFoundException();

        inputAction.Enable();

        Debug.Log($"{inputAction.phase} - {inputAction.ReadValue<float>()}");
    }
}

In the demo scene this prints "Waiting - 0":


I made an empty scene, added a camera, attached a Player Input with the same Opsive actions, and attached the test script:


I'm not convinced this is necessarily a Unity problem
 
Found the problem!

For some reason the light in the demo scene has a Player Input component, once I disable that I'm able to control the character.

7447bc1ed4999218df30864021f3c3b4.png
 
Oh, weird. I see it there as well. I'll remove it and update the integration. Glad it was an easy fix!
 
Top