I’m just starting out game development unity and I was trying to make some movement and Unity is giving me an error about MonoBehaviour. can anyone help? it says:
No MonoBehaviour scripts in the file, or their names do not match the file name.
the code is in visual studio 2019
Here is my code specifically for the the player motor:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMotor : MonoBehaviour
{
private CharacterController controller;
private Vector3 playerVelocity;
public float speed = 5f;
// Start is called before the first frame update
void Start()
{
controller = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
}
//recive the inputs for our InputManager.cs and apply them to the character controller.
public void processMove(Vector2 input)
{
Vector3 moveDirection = Vector3.zero;
moveDirection.x = input.x;
moveDirection.z = input.y;
controller.Move(transform.TransformDirection(moveDirection) * speed * Time.deltaTime);
}
}
I was trying to add the script to the player character but instead it gave me this unity error along with this message: “Please fix compile errors before creating new script components.”
Zimmer Person is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
From what I can see in your provided script:
You have a typo in TransFormDirection(), it should be TransformDirection().
Also, please provide all error message you have.
FlyingPolska is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3