所以我是 Unity 的新手,我正在遵循教程。 https://www.youtube.com/watch?v=34fgsJ2-WzM 但是当我编写代码时出现此错误。如果这是一个愚蠢的问题,我很抱歉。提前谢谢。
代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCtrl : MonoBehaviour
{
public float movSpeed;
float speedX, speedY;
Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
speedX = Input.GetAxisRaw("Horizontal") * movSpeed;
speedY = Input.GetAxisRaw("Vertical") * movSpeed;
rb.velocity = new Vector2(speedX, speedY);
}
}
我尝试调试并重写代码,问题仍然存在。