How can I create static floating information?

Hi
I would like to create a static floating information, like score, hp, etc.

It needs to be at the same place even if the camera is moving and to be the same on every level, even if changed, I want it to change on all the levels together so I won’t have to go over all the levels and redefine it.

kinda like a static frame of information.

Thanks :slight_smile:

Hi @SlowSpeed

If I am not wrong then you are talking about a animation will play in camera sapce, it’s dosnt matter what is the camear location. If YES, then it is very simple, just place animation object as child of camera, set position as per your aspect of view and then play your static animation.

Once you set your animation object as child of camera, it will also move with camera if move or rotated.

static floating information.
these are static public variables that can be accesed from another script. To access them from another script. you have to reference them as “ScriptName.hp” instead of hp in the other script.

  //script 1 with the variables.
 public class PlayerManager : MonoBehaviour {
    static public float hp;
    static public float score;


  //script2 - how to refer hp in another script
    PlayerManager.hp

While you go through the levels you want to safe the data. When the scene starts you want to call PlayerPrefs.GetFloat and when the scene ends you want to call PlayerPrefs.SetFloat.

It might also be worth to check DontDestroyOnLoad. Although I don’t know if this would work on variables inside a script. http://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html

The ideal idea would be to use a combination of both. Have a gameObject with the script that Gets and Set the PlayerPrefs and when loading another scene, dont destroy this gameObject so that you can carry this gameObject to multiple scenes without constantly re adding it to the scene