Click here to Skip to main content
15,917,174 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I've made a script to make the player go to "Sleep" but it keeps saying:

"The Type or namespace name "ThirdPersonController" could not be found (Are you missing a using directive or an assembly reference?)

heres my script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;

public class DisableManager : MonoBehaviour
{
[SerializeField] private ThirdPersonController player;

public void DisablePlayer()
{
player.enabled = false;
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}

public void EnablePlayer()
{
player.enabled = true;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}

What I have tried:

I've surfed the internet, watched tutorials but i cant seem to find what to do, I seriously need help to fix this issue.
Posted
Updated 7-Mar-21 21:37pm

What it's saying is the you are trying to use a class - called ThirdPersonController and it can't find it in the current project or the assemblies it references.

Since it's not a "standard class" you need to find the definition (or the assembly it is defined in) and add that to your project.
First find out where it is: if it's in a different assembly, then you need to check that you have added that to the project's References: open the Solution Explorer pane and check the References branch: if it's not there, use the right click "Add Reference..." option to locate and add it.
Then find out what namespace it is in, and add a using line to each file in your project that need to use it, just like you have for the Unity stuff in your code.
 
Share this answer
 
The error message is quite clear. You are missing a using statement to include the ThirdPersonController class. And as we have already suggested in previous questions, if you spent time learning C# properly from the basics up, you would understand why this is so. Repeatedly putting code together that you do not understand is just a waste of your time.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900