Hello
To make this easier to understand;
-My game is 2d side scroller (first game i’ve attempted).
-I have a character which can move left and right as well as jump(all animated) and the camera will follow the character with a script i basically copied from somebody else in the forums (I believe it’s a smooth camera, with damp time etc…).
Now my problem is getting a GUI text to display my score (top left preferable). I have tried looking online for tutorials but they’re all old and use unity 3d mode as opposed to the new 2d mode. I’ve tried almost everything but nothing seems to work
Any help is appreciated
Thanks in advance.
If your using Unity UI you can add a Text control and position it wherever you want in the canvas, then you could change the Text at anytime to almost anything by attaching a script like this
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ScoreText : MonoBehaviour {
public int Score;
void Update () {
GetComponent<Text>().text = Score;
}
}
to your Text control.
BTW that code is just to give you idea of what you could do, you can easily change it to work how ever you want it to
Hmm, have you tried the tutorials in the Learn section here?
In a nutshell you just right click on the hierargy panel and on the popup menu go to UI and just select Text from the list in the foldout menu. This will add in a Canvas with a child Text. Select the Canvas and while hovering over your scene press the f key to focus on it. Now just position your text element were you want it to go.
Greets,
Jan