I'm a beginner in unity so I got this problem. Here is the script:
using UnityEngine;
using System.Collections;
public class Playercontrol: MonoBehaviour {
public float maxspeed = 10f;
bool facingRight = true;
void FixedUpdate () {
float move = Input.GetAxis ("Horizontal");
GetComponent<Rigidbody2D>().velocity
= new Vector2(move * maxspeed, GetComponent<Rigidbody2D>().velocity.y);
if (move > 0 && !facingRight){
Flip ();
} else if (move < 0 && facingRight) {
Flip ();
}
}
void Flip() {
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
I don't know why but it keep saying that Can't add script component 'Player control' because the script class cannot be found.Make sure that there no compile errors and that the file name and class name match.