Hello everybody
,
I have a problem, so help me please.
How can I get a component from an object with c# script - object.GetComponent()
if ScriptExample is a java script.
using UnityEngine;
using System.Collections;
public class CountDown : MonoBehaviour {
private GameObject opponent;
void Start () {
opponent=GameObject.FindWithTag("aicar");
if(!opponent) {Debug.Log("don't exist the car");}
else{Debug.Log("exist the car");} // that part works fine.
}
void Update () {
GameStart();
}
public void GameStart() {
opponent.GetComponent<Aicar>().enabled=false; // ***
}
}
***the type or namespace ScriptExample could not be found. Are you missing a using directive an assembly reference?