- Home /
 
               Question by 
               BigCheefa · Jun 08, 2013 at 07:28 AM · 
                scriptingproblem  
              
 
              why when i try to add my script to the "player" it says can not can not add script
I am a noobie at this first script first game first everything so sorry in advance, but the script i try to apply to the empty box "game object" otherwise known as Player.
It says, "Can not add script behaviour FirstPersonController. The scripts file name does not match the name of the class defined in the script."
Obviously the scripts file name does not match the name of the class defined in the script but how do i fix this problem?
using UnityEngine; using System.Collections;
public class FirstPerson : MonoBehaviour {
 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
 
     float forwardspeed = Input.GetAxis("Vertical");
     
     Vector3 speed = new Vector3 ( 0, 0, forwardspeed );
     
     CharacterController cc = GetComponent();
         
     cc.SimpleMove ( speed );    
 }
}
               Comment
              
 
               
              Answer by saschandroid · Jun 08, 2013 at 09:36 AM
The name of the script and the class name have to be the same.
class name: FirstPerson file name: FirstPerson.cs
Rename you script (or your class).
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                