Hi, I am trying to create a coin animation in which a value moves up above the coin indicating the value of this coin.
My problem with this is that the positions that I am trying to take from the game objects themselves are very far off. Despite the fact that they are near the center of the screen their x
and y
coords are less than one.
Is there anyway that I can convert the values that I get from gameObject.transform.position
into values that correspond to the coins exact position in-game.
Any and all help is greatly appreciated.
EDIT:
Sorry for the lack of information, hopefully I can make it more clear what my problem is.
Ok so I have a coin (blue). Checking the position in the inspector I can see that x is 1.809
and y is 0.075
rounded to 3 decimal places.
Currently the scene looks like:
I have the coins set up so that when they are clicked a their value appears with a sound.
The code for writing the text to the screen is:
void OnGUI() {
if (this.displayText) {
Vector2 pos = gameObject.transform.position;
GUI.Label(new Rect(pos.x, pos.y, 30, 30), "+" + this.value.ToString());
}
}
this.value
is the value of the current coin. Using the positions I get from gameObject
the number ends up in the left corner.
As it seems in the scene view everything is being placed in the center of the screen so the values are skewed quite a lot.
Is there anyway that I can somehow convert the points of the coin object to points that can actually be used in-game to display the text directly above the coin?