Hi, I tried writing a simple 2D player movement script but when I tried to attach it to my player sprite, it just displayed an error message that said “The script doesn’t inherit a native class that can manage a script.” Could anyone help?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
public float Speed = 10f;
// Start is called before the first frame update
void Start() {
}
// Update is called once per frame
void Update() {
float Dirx = Input.GetAxis("Horizontal") * Speed * Time.deltaTime;
transform.position = new Vector2 (transform.position.x + Dirx, transform.position.y);
}
}