Answer the question
In order to leave comments, you need to log in
How to fix "No MonoBehavior scripts in the file, or their names do not match the file name" Unity C# error?
Here is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public float speed;
private Rigidbody2D rb;
private Vector2 moveInput;
private Vector2 moveVelocity;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
moveInput = new Vector2(Input.GetAxisRaw(Horizontal)
moveVelocity = moveInput.normalized * speed;
}
void FixedUpdate()
{
rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime);
}
}
Answer the question
In order to leave comments, you need to log in
If you throw an error message into Google translator, then everything becomes clear:
The file does not contain MonoBehaviour scripts or their names do not match the file name
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question