Unity3d 新输入系统不发送消息?
我正在使用Unity的输入系统,并已根据控制方案()定义了我的控件 我的播放器上有播放器输入组件和CharacterInput,用于处理播放器输入。我想实现SendMessages形式的输入,因此下面是配置: 最后,我在同一个对象上创建了CharacterInput类,代码如下:Unity3d 新输入系统不发送消息?,unity3d,Unity3d,我正在使用Unity的输入系统,并已根据控制方案()定义了我的控件 我的播放器上有播放器输入组件和CharacterInput,用于处理播放器输入。我想实现SendMessages形式的输入,因此下面是配置: 最后,我在同一个对象上创建了CharacterInput类,代码如下: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngi
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);
}
}
使用系统;
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
使用UnityEngine.InputSystem;
[RequiredComponent(typeof(Rigidbody2D))]
公共类特征输入:单行为
{
[字段]专用浮动速度;
私有刚体2d rb;
void Start()
{
rb=GetComponent();
}
无效更新()
{
}
移动时公共无效(输入值输入)
{
Debug.Log(“aha”);
Vector2 inputVec=input.Get();
HandleMove(输入向量);
}
私有无效句柄移动(INUPT中的矢量2)
{
transform.position+=新矢量3(fromInupt.x*速度*时间.增量时间,0,fromInupt.y*速度*时间.增量时间);
}
}
所以我的问题是WASD的输入没有输出调试消息。所以我的问题是,让PlayerInput调用OnMove时我错过了什么?我不得不在我的控制方案中使用
编辑控制方案将键盘和鼠标添加到表中…