I've been looking at this for about a hour and I don't get what's wrong...

The error I’m getting is

“The class defined in script file named ‘Playa_Controlla’ does not match the file name!”

it’s new. It didn’t used to do this.

using UnityEngine;
using System.Collections;

[System.Serializable]
public class Boundary
{
   public float xMin, xMax, zMin, zMax;
}

public class PlayaController : MonoBehaviour{
  public float speed;
  public Boundary boundary;
  public float tilt;
 
 
   void FixedUpdate (){
       float moveHorizontal = Input.GetAxis ("Horizontal");
       float moveVertical = Input.GetAxis ("Vertical");
    
       Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
       rigidbody.velocity = movement * speed;
    
       rigidbody.position = new Vector3
       (
           Mathf.Clamp (rigidbody.position.x, boundary.xMin, boundary.xMax),
           0.0f,
           Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax)
       );
    
       rigidbody.rotation = Quaternion.Euler (0.0f, 0.0f, rigidbody.velocity.x * -tilt);
   }
}

The ship won’t move. It used to. These errors are all new. I’m thinking perhaps my error is being caused by the editor not the code.

The error description gives you a hint :

The class defined :

public class PlayaController : MonoBehaviour

in script file named ‘Playa_Controlla’
does not match the file name!

and it doesn’t :slight_smile:

so either rename the file to “PlayaController”
or
rename the class to “Playa_Controlla”

2 Likes

Ugh



.

Apparently I’m missing something. I tried to follow your instructions… and failed.

I’m not exactly positive what’s wrong with my game.

Could you PLEASE download my project and fix it? And if you are awesome enough to do this, could you write down what you did, so I can learn?

All you need is to either rename the script file, or rename the class. “PlayaController” is different from “PlayaControlla” and one is the name of the script file, while the other one is the name of the class as you declared it inside the script file. They have to be the exact same name. It doesn’t matter which one you change to match the other, as long as they are the same in the end.

You have a class called “PlayaController” in the file named “Player Controller.cs”. What I would do is this: Rename file “Player Controller.cs” in your scripts folder to be “PlayerController.cs” (without a space) and in the code I would change line 10 from public class PlayaController : MonoBehaviour{ to public class PlayerController : MonoBehaviour{ This should fix your problem.

EDIT:
Please note that you should always name your files without any space characters. Computers tend to get confused by spaces in file names.

I don’t think that was it.

Please…

I don’t know AT ALL what’s wrong with my game.

I’m asking anyone who can see what I can’t to please download my project and just tell me what’s wrong? I could just walk through the tutorial again and program a working version of my game, but then I don’t know what mistake I’ve made and over time I might end up repeating it.

Ok…so let’s start differently. In what version of unity you started this project and what version of unity are you using now?

For me if I load your project in my unity, I get many errors about using obsolete stuff, maybe that is the problem here.

So If you updated unity or anything, you would probably need to change some stuff. I can tell you more when I know your Unity version