I feel incredibly dumb not knowing what to do. I have tried figuring this out since yesterday and still proves to be out of my grasp of solving this. It seems to me that the private game objects that I had set for myself is clearly (at least to me) been assigned but it continues to say that it is not. Is it the way I set my script up? How can I remember next time not to trip over myself on this problem that seems deceptively easy? Any advice would be very appreciated.
using UnityEngine;
using System.Collections;
public class ChangeToSecondForm : MonoBehaviour
{
private static ChangeToSecondForm instance = null;
public static ChangeToSecondForm Instance
{
get {return instance; }
}
private GameObject playerToBeChangedFrom;
private GameObject playerChangingTo;
public Transform secondFormDisplay;
public int maxEnergy = 100;
public int currentEnergy;
private float energyOriginalXScale;
// Use this for initialization
void Start ()
{
currentEnergy = 0;
energyOriginalXScale = secondFormDisplay.localScale.x;
playerToBeChangedFrom = GameObject.FindGameObjectWithTag ("PlayerCharacter");
playerChangingTo = GameObject.FindGameObjectWithTag ("PlayerCharacterSecondForm");
}
// Update is called once per frame
void Update ()
{
if (currentEnergy <= 0)
{
secondFormDisplay.GetComponentInChildren<Renderer>().enabled = false;
}
if (Input.GetButtonDown ("TransformToSecond") && (currentEnergy == 100))
{
Debug.Log("Q has been pressed");
currentEnergy = 0;
}
}
public void GatherEnergy(int energyGathered)
{
Debug.LogError ("Got Energy from dead enemy.");
currentEnergy += energyGathered;
if (currentEnergy > 100)
{
currentEnergy = 100;
}
secondFormDisplay.localScale = new Vector3(energyOriginalXScale * (currentEnergy/maxEnergy), secondFormDisplay.localScale.z, secondFormDisplay.localScale.z);
}
}