Changing Apearence using Scripts
Hello. It's a little bit of a Complicated Question and I'm not sure if anyone can actually help me, maybe you just can't do what i want in unity(I think i can though which is why i'm asking here).
Here's what i got
I got 6 Character images
4 Scripts controlling them
Here's what i have in Scripts
Reusable Controller for Each image
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Wake : MonoBehaviour {
public Image puciek;
public int TargetAge;
public int toohighAge;
public AgeCounter aC;
public FaceControll fC;
public SleepCycle sC;
void Update()
{
if (sC.awake == true) {
if (aC.ageNum >= TargetAge && aC.ageNum <= toohighAge) {
puciek.enabled = true;
} else
{
puciek.enabled = false;
}
fC.faceCycle = true;
} else {
if (sC.awake == false) {
puciek.enabled = false;
fC.faceCycle = false;
}
}
}
}
A sleep cycle that switches between a sleeping state and awake state of the Character
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class SleepCycle : MonoBehaviour {
public FaceControll fC;
public Wake wake;
public Sleep sleep;
public int time;
public float delay = 100.0f;
public bool awake;
private bool delayAdd;
void Start ()
{
awake = true;
}
void Update ()
{
delay -= Time.deltaTime;
if (awake) {
sleep.image.enabled = false;
} else {
if (!awake) {
sleep.image.enabled = true;
}
}
if (delay > 50) {
awake = true;
} else {
if (delay < 50) {
awake = false;
if (delay < 0)
{
delay = 100;
}
}
}
}
}
Age Controll of the Character
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class AgeCounter : MonoBehaviour {
public Text ageCount;
public int ageNum = 0;
public EXP experience;
public int targetExp = 25;
void FixedUpdate ()
{
if (experience.experiencePS >= targetExp)
{
ageNum += 1;
targetExp += 10;
}
}
void Update()
{
ageCount.text = "Age: " + ageNum;
}
}
The Face controll is pretty simple so i'll leave it out, It just switches between 3 faces that are independent of the player character itself.
TheProblemitself I can't get the Character Images to SWITCH, all of them are on the screen at once, I don't want that. I could use a simple fix to my problem that doesn't include revising the whole Game system i built there .-.