The referenced script on this Behaviour is missing! | Help Fast :/
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Playermovement : MonoBehaviour { public float speed = 6f; public float gravity = 20f;
CharacterController controller;
float horizontal;
float vertical;
Vector3 moveDirection = Vector3.zero;
// Start is called before the first frame update
void Start()
{
controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
if (controller.isGrounded)
{
moveDirection = new Vector3(horizontal, 0.0f, vertical);
moveDirection *= speed;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
}

,using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Playermovement : MonoBehaviour { public float speed = 6f; public float gravity = 20f;
CharacterController controller;
float horizontal;
float vertical;
Vector3 moveDirection = Vector3.zero;
// Start is called before the first frame update
void Start()
{
controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
if (controller.isGrounded)
{
moveDirection = new Vector3(horizontal, 0.0f, vertical);
moveDirection *= speed;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
}

Answer by Bunny83 · Jan 27, 2020 at 12:44 PM
You most likely renamed your script while it was already attached to a gameobject / prefab.
Make sure:
The file name of your script file matches exactly your class name. Since you named your class
Playermovementyour file has to be namedPlayermovement.cs. Note the casing has to match as wellIf you renamed your script after you attached it to a gameobject, make sure to remove the old instance and re-attach the new one.
Your answer
Follow this Question
Related Questions
Object Player Movement stops working after Restarting Unity 0 Answers
Press on object, and be able to control that object you pressed on. 0 Answers
How do I get a character to walk on walls and ceilings? 1 Answer
How to move a cube by flipping using keyboard input 1 Answer
Movement worked yesterday but doesn't anymore? I did not make any changes in script 2 Answers