everybody. I'm beginner unity user. When i study unity. my C# script file doesn't insert to prefabs. And it return error message : The script don't inherit a native class that can manage a script.
this is my C# script code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class unPlayerMovement
{
private Transform tr;
public float moveSpeed = 30.0f;
public float rotSpeed = 150.0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
tr = GetComponent<Transform>();
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Mouse X");
float v = Input.GetAxis("Vertical");
Move();
}
void Move(float h, float v)
{
tr.Rotate(0, v * moveSpeed * Time.deltaTime, 0);
tr.Translate(0, 0, h * rotSpeed * Time.deltaTime);
}
}
And this is my Unity screen.
enter image description here
Just had this issue too. Check the class name is the exact same as the file name, this fixed it for me.
In your case check the class unPlayerMovement
is in a file called unPlayerMovement.cs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With