Unexpected error while game still runs perfectly

Hi!

I’m new to Unity, and I just got two errors that I don’t really understand.
The console in Unity gives me two red errors saying:

I’m not exactly sure what I’m doing wrong.
The game still runs and nothing seems wrong there, but I don’t want to continue before that error is fixed.

I only have one script in the game so far, which is this:

using UnityEngine;
using System.Collections;

public class Controller : MonoBehaviour
{

    public GameObject grassplot;
    public GameObject trainstation;
    private Vector3 movement;
    private float horizontal;
    private float vertical;

    // Use this for initialization
    void Start ()
    {
        GameObject plottedgrass;
        for(int i = 0; i < 41; i++)
        {
            for(int j = 0; j < 41; j++)
            {
                plottedgrass = Instantiate (grassplot);
                plottedgrass.transform.position = new Vector3 (i*2-40f, 0, j*2-40f);
            }
        }
        GameObject plottedtrainstation;
        plottedtrainstation = Instantiate (trainstation);
        plottedtrainstation.transform.position = new Vector3 (32, 0, 2);
    }
   
    // Update is called once per frame
    void Update ()
    {
        horizontal = Input.GetAxisRaw ("Horizontal");
        vertical = Input.GetAxisRaw ("Vertical");
        movement = new Vector3 (horizontal, 0, vertical);
        transform.Translate(movement * 5f * Time.deltaTime,Space.World);
    }
}

I hope someone can help me out :slight_smile:
Thanks in advance!

Do you have any scripts attached to the prefabs you are using?

The other thing I get that is similar in that I get errors unrelated to my scene is when I’m using a test project. I have a test project where I just create scenes to test different mechanics & I often get console errors relating to scripts used in the other unrelated scenes. When I strip out everything from the project except the stuff I’m currently working on those errors disappear.

1 Like

Hmm the prefabs that are mentioned in my script have no scripts attached. It’s really just a bare project with only 1 scene, one script, a camera, a light object and a few prefabs. Maybe I can just start all over again and see if the problem persists?

Maybe.

Im assuming you don’t have any animation components on the objects? The path it is showing, is that where your project is being saved?

1 Like

Really weird, but I restarted Unity after having saved the scene as a new scene and having deleted the old one, and the errors are now gone :stuck_out_tongue:
Hopefully it’ll stay like that :slight_smile:
Thanks for the help anyway!