Im confused can you help?

What does it mean by class and filename have to match?
It also says game object player is missing.How do i fix that?
The reference script on the behavior is missing. How do i fix this also
Thanks again

It means that if your script has the filename “MyClass.cs”, then the class inside has to be named like this:

public class MyClass : MonoBehaviour

If the file was called “Apple.cs”, then the class would have to be named like this:

public class Apple : MonoBehaviour
1 Like

It says that the class cannot be found?

What says that?

Mind sharing your whole script? and maybe a screenshot of Unity (inspector and console are what I’m interested in seeing - wherever you have an error)

Heres my script

using UnityEngine;
using System.Collections;
public class Player1 : MonoBehaviour PlayerController : MonoBehaviour
{
    public float speed = 5f;
private float movement = 0f;
private Rigidbody2D rigidBody;
public float jumpSpeed = 8f;

// Use this for initialization
void Start()
{
    rigidBody = GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
    movement = Input.GetAxis("Horizontal");
    if (movement > 0f)
    {
        rigidBody.velocity = new Vector2(movement * speed, rigidBody.velocity.y);
    }
    else if (movement < 0f)
    {
        rigidBody.velocity = new Vector2(movement * speed, rigidBody.velocity.y);
    }
    else
    {
        rigidBody.velocity = new Vector2(0, rigidBody.velocity.y);
    }
    movement = Input.GetAxis("Horizontal");
    if (movement > 0f)
    {
        rigidBody.velocity = new Vector2(movement * speed, rigidBody.velocity.y);
    }
    else if (movement < 0f)
    {
        rigidBody.velocity = new Vector2(movement * speed, rigidBody.velocity.y);
    }
    else
    {
        rigidBody.velocity = new Vector2(0, rigidBody.velocity.y);
    }
}
}

this is wrong:public class Player : MonoBehaviour PlayerController : MonoBehaviour
Pick one:
public class Player : MonoBehaviourorpublic class PlayerController : MonoBehaviourBut not both. And remember it needs to match the filename

2 Likes

Thanks