2D角色在Unity中不移动,使用按键.脚本似乎是正确的.请验证代码和检查员



![这就是我的检查员的样子](检查员图像(

这是脚本:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public float speed = 10f;
// Start is called before the first frame update
void Start()
{

}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector2 Movement = Vector2.zero;
Movement.y = v;
Movement.x = h;
transform.Translate(Movement * speed * Time.deltaTime);
}
} // class

不,提高速度来检查它是否移动得真的很慢,并没有帮助:(

您需要在检查器或启动函数中设置正确的值。

void Start()
{
speed = 10f;
}

检查员图像

相关内容