lundi 11 janvier 2016

C# RNG, Unity UI text to Script

I'm trying to code a text based game using the unity engine. I've got my errors narrowed down to three.

Error CS1061: Type UnityEngine.UI.Text does not contain a definition for HP of type Unity.Text

Error CS1061: Type Unity.Engine.Random does not contain a definition for Next and no extension method Next of type UnityEngine.Random

I can narrow down the errors to these lines:

Next error:

Random rnd = new Random();
                int month = rnd.Next(1, 13);

HP Error: public Text HP; text.HP = "HP: " + healthPoints;

I really don't understand the RNG for C#. C++ no problem I know what I need to include for it. All the searches I've done for C# I can't figure the RNG out or what's needed.

As for the HP I have a text object on my UI named HP. I've linked it to the script, but where previously the engine listed SCRIPT and then TEXT below on main screen there's no TEXT area to drag HP into. I'm not sure how to change that UI object through my script.




Aucun commentaire:

Enregistrer un commentaire