简体   繁体   中英

error CS0246: The type or namespace name 'PlayerMotor' could not be found

I'm making up my first game in unity and this error is showing up i don't know if i can use a "using" tag would fix this problem or not and i don't know which one

    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
                }
            }
        }
    }

You require the game object to have a "PlayerMotor" Component.

Did you define a PlayerMotor class? If not then define it, as the compiler can not find the class.

If yes then check if it's in your project directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM