I have a Game Object ghostBuddy (with a collider) with script GhostBuddy.cs as here:
using UnityEngine;
using System.Collections;
namespace GameScripts.BalloonBalance {
public class GhostBuddy : MonoBehaviour {
public bool isInsideGhost = false;
void OnTriggerEnter2D (Collider2D other)
{
if (other.gameObject.GetComponent() || other.gameObject.GetComponent()) {
isInsideGhost = true;
}
}
}
}
and I am trying to check from the game manager if isInside Ghost is true , by setting:
public GameObject ghostBuddy;
void Awake() {
ghostBuddy = (GameObject)Instantiate (Resources.Load ("Prefabs/GhostBuddy"));
}
void FixedUpdate () {
currentPoolSize = pool.Count;
if (shouldIDraw) {
if ((ghostBuddy.GetComponent () != null)) {
if (ghostBuddy.GetComponent NullReferenceException: Object> reference not set to an instance of an> object> GameScripts.BalloonBalance.GhostBuddy.FixedUpdate> () (
but couldn't figure out why because I have instatitated everything properly.
↧