- Home /
Several problems: variables references, managing and displaying variable values in the GUI
I'm trying to create a new prefab in my game that is basically a trap. If the player (a first person controller) passes through the trigger it should decrease the variable lives, reposition the camera controller back to start and display the lives new value in the GUI. However:
besides the trigger is being correctly activated and calling the OnTriggerEnter callback function and decreasing the variable "LIVES" value properly, the change is not being displayed in the OnGUI function (with GUI.Label). Oddly is that I have a similar approach for the POINTS variable that works perfectly running in the same function! Another problem is that once the lives value changes it never come back to its original value (even after I stop the game, thus obligating me to close the scene and reopen it just to reset the initial value for this var.
Another problem i'm experiencing seems to be a bug in UNITY: I declared a public GameObject camPlayer and set a value for it in the Inspector. However, Unity keeps reporting an unassigned variable error on it!
Your answer
Follow this Question
Related Questions
Keeping track of variables? 0 Answers
Inventory Cursor Location 1 Answer
Help with GUIText health bar please 1 Answer
How to make a Score GUI. 0 Answers
GUI buttons referencing wrong object. 0 Answers