Script error

So, I found an old scene I was working on which contained a cube, plane and a simple script to move the cube, works perfectly. When I paste this code into a new scene with a new cube and plane, i get the error "Associated script can not be loaded, please fix compile errors. as far as I can see it compiles fine.
Here is the code, any help would be greatly appreciated. (console "the referenced script on this behavior (main object camera) is missing.

using UnityEngine;
using System.Collections;

public class movement : MonoBehaviour
{
public float speed = 5.0f;

void Update ()
{
if (Input.GetKey (KeyCode.UpArrow))
{
Debug.Log (“Key UpArrow Pressed.”);

this.transform.Translate (new Vector3 (0, 0, speed * Time.deltaTime));
}

else if (Input.GetKey (KeyCode.DownArrow) )
{
this.transform.Translate (new Vector3 (0, 0, -speed * Time.deltaTime));
}

else if (Input.GetKey (KeyCode.LeftArrow) )
{
this.transform.Translate (new Vector3 (-speed * Time.deltaTime, 0, 0));
}
else if (Input.GetKey (KeyCode.RightArrow) )
{
this.transform.Translate (new Vector3 (speed * Time.deltaTime, 0, 0));
}

}

}

I don’t think the error is where you think it is. Please post a screen shot of your Unity window, showing the error and the object you believe it’s about.

(And when you post code, please do it in code tags — use the “Insert…” button, just to the right of the movie filmstrip in the toolbar.)

Sorry, was looking for that everywhere, thanks.

3410178--268608--Untitled.png

Well, your file is called move.cs, but your class is called movement. That’s no bueno. MonoBehaviour classes must match the file name.

I thought it would be something like that, I haven’t used unity in so long so im just getting used to everything again,. thank you so much for your help.

1 Like