I’m not getting any parser errors and everything should be working fine. Below I’ll post the script with the message that is failing to log and below that will be part of the script that I’m trying to access. Thank you for any help you can provide!
using UnityEngine;
using System.Collections;
public class Sombrero : MonoBehaviour {
public GameObject Player;
void Start() {
}
void update() {
GameObject thePlayer = GameObject.Find("Triangle");
PlayerController playerscript = thePlayer.GetComponent<PlayerController>();
if (playerscript.health == 5) {
Debug.Log("Low HP");
}
}
}
using UnityEngine;
using System.Collections;
And here is the list of variables from my player controller that I’m trying to access. My goal here is to add a function to my sombrero game object when the health reaches a certain point.
public class PlayerController : MonoBehaviour {
public float speed = 5f;
public float bumper;
float xmin;
float xmax;
public GameObject taco;
float projectileSpeed = 15f;
public float fireRate = 5f;
public float health = 5f;
}