Question by
ChrisAnderson · Jan 28, 2017 at 05:00 PM ·
animationbooleanboolcheck
Changing eye texture using bools
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
void Start()
{
}
// Update is called once per frame
void Update()
{
//if (Input.GetKeyDown(KeyCode.Space))
//if (cry == true)
//if (GameObject.Find("Chao").GetComponent<ChaoNeeds>().cry == true)
if (gameObject.GetComponent <ChaoNeeds>().cry)
{
currentTexture++;
currentTexture %= textures.Length;
GetComponent<Renderer>().material.mainTexture = textures[currentTexture];
}
}
}
Any help is appreciated.
Comment
Your answer
Follow this Question
Related Questions
Animator Boolean not changing to true in C#, 0 Answers
PROBLEM WITH ANIM.SETBOOL NOT WORKING 0 Answers
check if-statement/bool when button is pressed? 1 Answer
If statement not working 1 Answer
Get Time A Bool Has Been True 4 Answers