using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class runningDebug : MonoBehaviour {
Text running;
// Use this for initialization
void Start () {
getCharacter = GameObject.Find("Character").GetComponent<CharacterController>();
running = GetComponent<Text>();
}
so i’m trying to shorten GameObject.Find(“Character”).GetComponent();
to just getCharacter but i don’t know how to store it as a variable properly
help please!
@tas41
Before any variable in C# can be assigned a value it needs to be declared. The getCharacter variable is missing a declaration. Include a CharacterController declaration as in the following:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class runningDebug : MonoBehaviour
{
CharacterController getCharacter;
Text running;
// Use this for initialization
void Start()
{
getCharacter = GameObject.Find("Character").GetComponent<CharacterController>();
running = GetComponent<Text>();
}
}