- Hello,
I’m attempting to change the texture of an NPC’s eyes using bools. This is the script I’ve written to check a bool from another script and change the texture if it is true. I can use the Input function to change the eye texture, but all of the bool checking lines I wrote are not working.
using UnityEngine; using System.Collections;
public class ChangeEyes : MonoBehaviour { public Texture[ ] textures; public int currentTexture;
- // Use this for initialization
- voidStart()
- {
- }
- // Update is called once per frame
- voidUpdate()
- {
- //if (Input.GetKeyDown(KeyCode.Space))
- //if (cry == true)
- //if (GameObject.Find(“Chao”).GetComponent().cry == true)
- if(gameObject.GetComponent().cry)
- {
- currentTexture++;
- currentTexture %= textures.Length;
- GetComponent().material.mainTexture = textures[currentTexture];
- }
- }
}
Any help is appreciated.