【发布时间】:2021-11-24 10:42:54
【问题描述】:
在尝试将脚本添加到游戏对象时,我反复收到错误消息。到目前为止,我已经尝试将 MonoBehavior 类名称更改为脚本名称,并检查了我的代码是否有错误,尽管终端中没有显示任何错误。这是我的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace LE
{
public class InputHandler : MonoBehaviour
{
public float horizontal;
public float vertical;
public float moveAmountl;
public float mouseX;
public float mouseY
PlayerControls inputActions;
Vector2 movementInput;
Vector2 cameraInput
public void private void OnEnable() {
{
if (inputActions == null)
{
inputActions = new PlayerControls();
inputActions.PlayerMovement.Movement.performed += inputActions => movementInput = inputActions.ReadValue<Vector2>();
inputActions.PlayerMovement.Camera.performed += i => cameraInput = i.ReadValue<Vector2>();
}
inputActions.Enable();
}
private void private void OnDisable()
{
inputActions.Disable();
}
}
public void TickInput(float delta)
{
MoveInput(delta);
}
private void MoveInput(float delta)
{
horizontal = movementInput.x;
vertical = movementInput.y;
moveAmountv= Mathf.Clamp01(Mathf.Abs(horizontal) + Mathf.abs(vertical));
mouseX = cameraInput.x;
mouseY = cameraInput.y;
}
}
}
【问题讨论】:
-
错误是什么?
标签: c# unity3d game-development