Input.GetRawAxis 为什么以及在哪里请求前缀?

Input.GetRawAxis Requesting a prefix why and where?

我正在为我的角色扮演游戏制作一个自上而下的移动系统,它说明我需要前缀“;”在第 32 行和第 33 行的末尾。我的代码有什么问题?

Unity 中的错误是:

Assets\PlayerController.cs(32,21): error CS1002: ; expected

Assets\PlayerController.cs(33,21): error CS1002: ; expected

代码

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

public class PlayerController : MonoBehaviour
{

    public float moveSpeed;
    private Rigidbody2D rb;
    private float x;
    private float y;

    public Vector2 Input;

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        MovementInput();
    }
    private void FixedUpdate()
    {
        rb.velocity = input * moveSpeed;
    }
    void MovementInput()
    {
 32       float speed x = Input.GetAxisRaw("Horizontal", * Time.deltaTime);
 33      float speed y = Input.GetAxisRaw("Vertical", * Time.deltaTime);

        Input = new Vector2(x, y).Normalize;
    }
}

我应该可以写一个更新方法,谢谢

   void Update()
 {
  float vertical = Input.GetAxis("Vertical");

  float horizontal = Input.GetAxis("Horizontal");

  transform.Translate(new Vector2(horizontal, vertical) * Time.deltaTime * speed);
 }

您正在尝试乘以一个字符串

float speed x = Input.GetAxisRaw("Horizontal", * Time.deltaTime);

相反,您需要这样做:

float speedx = Input.GetAxisRaw("Horizontal") * Time.deltaTime;

您应该收到来自 Input 的值,然后您需要乘以增量时间。