- Home /
Error CS0103 first time C#
This is my first program in C# so I'm sorry if this is a dumb question but it says that 'GetComponent' does not exist in the current context.
Here's the code:
using UnityEngine;
using System.Collections;
public class FirstPersonController : MonoBehaviour {
public float movementSpeed = 5.0f;
private Vector3 GetComponent;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float forwardSpeed = Input.GetAxis("Vertical") * movementSpeed;
Vector3 speed = new Vector3 (0, 0, forwardSpeed);
CharacterController cc = GetCompotent<CharacterController> ();
cc.SimpleMove(speed);
}
}
Thanks in advanced if you're able to help :D
Comment
Answer by robertbu · Aug 14, 2014 at 06:25 AM
For future posts, please include a copy of the error message from the console. It gives is the line number of the error and the stack trace.
Your problem is on line 22. You've misspelled 'GetComponent', plus you need to specify a game object. The line should be:
CharacterController cc = gameObject.GetComponent<CharacterController> ();
Thank you I feel like an idiot I will be sure to include the error messages next time