Question by
flybythenight · Oct 02, 2016 at 05:40 AM ·
script error
Im having a problem with my C# code
Can't add script component 'charactercontroller' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match. I only get this message when i try to drag and drop my code in to the objects componant list thingy.
Please help me Im probberly just misunder standing but i really want to know whats wrong. using UnityEngine; using System.Collections;
public class carachercontoler : MonoBehaviour {
public float speed = 10.0F;
// Use this for initialization
void Start () {
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update () {
float translation = Input.GetAxis ("Vertical") * speed;
float straffe = Input.GetAxis ("Horizontal") * speed;
transform.Translate (straffe, 0, translation);
if (Input.GetKeyDown ("escape"))
Cursor.lockState = CursorLockMode.None;
}
}
screen-shot-2016-10-02-at-120222-pm.png
(31.4 kB)
Comment
Answer by Anonymou5 · Oct 02, 2016 at 09:09 AM
Are you sure you have exactly the same name in the script and name with script is saved? charactercontroller.cs
public class carachercontoler : MonoBehaviour {
//carachercontroller or charactercontroller?
public class charactercontroller : MonoBehaviour {
sorry my bad english :P
Change the name in the script to
public class charactercontroller : $$anonymous$$onoBehaviour {