Hey there,
My game is going to have images displayed as commands for the player to follow.
Right now I am using text instead of images as debug, now I have my images I am having trouble with getting them to work.
I tried guiTexture.texture but it didn’t work right.
But here is my code with the debug text:
using UnityEngine;
using System.Collections;
public class Commands : MonoBehaviour {
public float Speed = 0.5f;
public static int Command = 0;
public float TimeLeft = 0;
void Start (){
Command = Random.Range(0,5);
}
void Update (){
TimeLeft += Time.deltaTime;
if(TimeLeft >2)
{
Respawn();
}
transform.Translate(Vector3.up * Time.deltaTime * Speed); // Translate it up
if(transform.position.y >= 1.65f) // Respawn it
{
Respawn();
}
switch(Command)
{
case 1:
guiText.text = "Mouth";
break;
case 2:
guiText.text = "Eye";
break;
case 3:
guiText.text = "Nose";
break;
case 4:
guiText.text = "Ear";
break;
}
}
public void Respawn (){
TimeLeft = 0;
transform.position = new Vector3(Random.Range(0.2f,0.9f), 0.4f, transform.position.z);
Command = Random.Range(1,5);
}
}
Any help would be appreciated