- Home /
Update function won't update?
Right... Not sure if this is a problem with my coding or the update function is just like... Not working. Also, the Instantiated items are destroyed and then the variables are edited... and so I want to re instantiate them after they have been destroyed. Hope you guys can help me out here.
Here's my code :
 public class IncrShieldHealth : MonoBehaviour {
 
     public static int IncrCost = 400;
     public bool notenough = false;
     public int s = 0;
 
     public GameObject Locked;
 
     public GameObject notEnough;
     public Transform notE;
 
     Text text;
 
     void Start()
     {
         Instantiate (Locked, notE.position, notE.rotation);
         Instantiate (notEnough, notE.position, notE.rotation);
     }
 
     void Update()
     {
         if (ScoreKeeper.Money > IncrCost) {
             if (s == 0) {
                 Instantiate (notEnough, notE.position, notE.rotation);
                 s = s + 1;
             }
         }
     }
Can you confirm if the Update function is even being called, using a Debug.log command, right at the top of it? Note: the GameObject must be "ACTIVE" in order to run update.update function is just like... Not working
Are you using the using statements?
 using UnityEngine;
 using System.Collections;
Answer by Cheese_Gaming · Jan 09, 2015 at 12:47 AM
Is this script attached to a GameObject? If it is not attached to a game object, it will not run. If the game object is destroyed, the script will no longer run. I see no reason that this should not work, other than if it were not attached to a GameObject.
That it mate thanks! I attached it to a UI Button so yeah... I thought it was going to be used but no apparently not. Thanks again.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                