Forum rules - please read before posting.

How to display a Global variable score as 3D scene text?

edited October 2016 in Technical Q&A
I have created a Global variable in AC. It is set to be an Integer and I am using it as a score, which is incremented on hotspot clicks.

How can I use this ‘score’ I have on my AC global, and display it in my 3D world? I have created, for example, a standard unity 3D text object, which I can position in my scene, but how to update the text itself from the AC global? I would need to be able to update the text output each time the score is updated. I had planned to do this also for globals set as ‘string’.

Comments

  • Welcome to the forum, @TheBear.  There are two ways you can do this:

    1) Link your Unity UI to AC's Menu Manager, so that your UI Text box is controlled by AC, which you can then set to display the value of the variable using tokens, i.e:

    Score: [var:X]

    Where X it the ID number of the variable - see this tutorial for more on showing the score.  If you go down this road, I would recommend first making the Menu using AC's built-in menu system until you're happy with the functionality, before switching over to Unity UI (which can be set to render in World Space and hence 3D).  This process is covered in this tutorial.

    2) If you would prefer to keep away from Unity UI, or simply control a 3D Text object yourself, you can read the value of any AC variable via script, and so write a script that copies the value onto your Text object.  See the front page of the scripting guide for how you can do this, but essentially it's:

    AC.GlobalVariables.GetIntegerValue (X);

    Again, where X is the ID number of the variable.  You can see the ID number of a variable on the left-hand side of it's label in the Variables Manager.

    You could read this and write to the 3D Text in an Update function, or if you wanted to literally only update it when the variable changes value, you can place the code in a custom Action and place it in your scene's "On Variable Change" Cutscene.
  • Thank you, I shall give that all a try :)

  • Hello there. I realise this is quite an old discussion, but did you manage to get 3D text working? I'm trying to do something similar but not getting very far. I'm curious what you did in the end.
  • I never got this working but will be returning to this same issue again...
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.