Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The script don't inherit a native class that can manage a script

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

like image 862
사랑수학 Avatar asked Sep 06 '25 03:09

사랑수학


1 Answers

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

like image 59
bolt19 Avatar answered Sep 07 '25 21:09

bolt19