Answer the question
In order to leave comments, you need to log in
GetComponent(); Explain?
In general, now for some reason in any C # script in Unity it does not work. GetComponent<GameObject>();
The script hangs on the Cube, the object is on the game stage, as this function stopped working, the script did. But the value of the variable is still null.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestGetComponent : MonoBehaviour {
private GameObject HeroObject;
private void Start()
{
HeroObject = GetComponent<GameObject>();
}
private void Update()
{
Debug.Log(HeroObject);
}
}
HeroObject = GetComponent<GameObject>();
HeroObject = this.GameObject;
private Animator ch_anim;
private void Start()
{
ch_anim = GetComponetn<Animator>();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question