Jaaz Cole
Jaaz Cole

Reputation: 3180

New Input System not Sending Messages?

I'm using Unity's Input System, and have defined my controls per the Control scheme (Control Scheme )

I have the Player Input component on my player, and my CharacterInput, to process the Player Input. I wanted to implement the SendMessages form of input, so here's the config:

enter image description here

Finally, I have my CharacterInput class on the same object, here's the code:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

[RequireComponent(typeof(Rigidbody2D))]
public class CharacterInput : MonoBehaviour
{
    [SerializeField] private float speed;
    private Rigidbody2D rb;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    void Update()
    {
        
    }

    public void OnMove(InputValue input)
    {
        Debug.Log("aha");
        Vector2 inputVec = input.Get<Vector2>();
        HandleMove(inputVec);
    }

    private void HandleMove(Vector2 fromInupt)
    {
        transform.position += new Vector3(fromInupt.x * speed * Time.deltaTime, 0, fromInupt.y * speed * Time.deltaTime);
    }
}

So my problem is that input of WASD doesn't output the debug message. So my question is, what have I missed in getting PlayerInput to call OnMove?

Upvotes: 3

Views: 4147

Answers (1)

Zach Long
Zach Long

Reputation: 76

I had to add keyboard and mouse to the table in my control scheme with the Edit Control Scheme...

Screenshot of Unity Control Scheme editor

Upvotes: 6

Related Questions