我正在统一制作我的第一款游戏,并且出现此错误,我不知道我是否可以使用“ using”标签来解决此问题,而且我也不知道哪一个
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(PlayerMotor))]
public class PlayerController : MonoBehaviour
{
public LayerMask ourMovmentMask;
Camera cam;
PlayerMotor motor;
// Start is called before the first frame update
void Start()
{
cam = Camera.main;
motor = GetComponent<PlayerMotor>();
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 100, ourMovmentMask))
{
Debug.Log("we hit " + hit.collider.name + " " + hit.point);
// move player to what we hit
// stop focusing any objects
}
}
}
}
答案 0 :(得分:0)
您需要游戏对象具有“ PlayerMotor”组件。
您是否定义了PlayerMotor类?如果没有,请定义它,因为编译器找不到该类。
如果是,则检查它是否在您的项目目录中