EDIT/UPDATE: Okay, figured it out. I was camelcasing the onEnable, (supposed to be OnEnable)
I have scoured the official documentation, watched dozens of youtubers as well as the unity lecture on the new input system and I still cannot get this input system to work in the most basic capacity…
I can’t get the Player Input component to send GameObject.SendMessages() calls on all my player action methods. My onWhatever methods just won’t trigger from these at all… no errors in console, no warnings… it just won’t trigger any of them even though these methods are listed in the box beneath the dropdown selector in the inspector (onWalk, onLook, onJump, etc). They just. aren’t. triggering. like the official documentation says they should here: GameObject components for input | Input System | 1.0.2
So I moved on to sending Unity Events instead (started, performed, canceled etc) using callbacks, and no matter what I do, nothing will compile because I get an error no matter what I change or how I much i hack around with the order of things. Not gonna lie… I’m definitely spoiled by how well chrome and firefox dev tools consoles log errors. This console is… well… bad. I’ve been crawling further and further down rabbit holes that are so far abstracted from what I’m trying to do that I’ve wasted two days on this by now, just by trying to debug using the vague console error feedback. Whokay I’m ranting here is my code right now:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class playerMove : MonoBehaviour
{
public InputControl Actions;
void Awake()
{
Actions = new InputControl();
Actions.Player.Move.performed += Move;
}
void onEnable()
{
Actions.Enable();
}
void onDisable()
{
Actions.Disable();
}
void Move()
{
print("HEY");
}
void Update()
{
}
}
This gives me: Assets\Controllers\Player\playerMove.cs(12,9): error CS0123: No overload for ‘Move’ matches delegate ‘Action<InputAction.CallbackContext>’
Which is related to the callback or its syntax or something… something that I’ve never seen anyone in these videos or in documentation mention, even when using something in exactly this syntax, ie. Brackeys has a video doing this. The official documentation examples appear to use this methodology, though I can’t be sure because they are just vague snippets with no real context. (ugh, just longing for some MDN-tier documentation here, my firefox privilege is showing lmao)
I’ve tried bypassing this and using polling with isTriggered as per official docs, and then I get a different error about not having InputAction.CallbackContext, so I’m thinking, okay, I’ll just add the argument to the params in function declaration, and whamo, now I get another error because when I call the function I don’t have the actual parameter in function call in Update(). Nobody anywhere that I can find an example of is using the polling method, and I’ve mirrored just about every tutorial or doc example I’ve seen.
Just to be sure I’ve covered my bases, so far I do things in (generally) this order:
-
Import input system and auto restart via package manager
-
Create the player action asset using the menu and program my player action map to actions bound with keys and/or vector2 axis (for wasd)
-
Save asset, generate C# class
-
Create Player Input component, link asset
-
Create player movement script, drag it to player object
-
Edit player movement script, referencing generated C# class
My brain is telling me to scrap the entire player action asset business as well as the player input component and just go straight to intercepting the events in C#, but if I’m gonna be circumventing everything I might as well switch to unreal at that point so I’m hoping someone here can steer me in the right direction.