So I have a small project which revolves around the player collecting pick ups, and when they collect them I want a small bit of text to temporarily show up displaying the value of the pick up. I have so far created a text prefab and attached it to the script controlling the pick up which instantiates it upon collision with the player. I then set it as a child to the canvas so that it becomes visible. The issue is, even though in the instantiate function I set up puts its position to the transform.position of the pick up object the text always appears at the very left edge of the screen no matter where the object that spawns it was collected. the following is the code that instantiates the text:
fling.score += value;
text = Instantiate(plus10, transform.position, Quaternion.Euler(0, 0, 0));
text.transform.SetParent(canvas.transform, true);
if (fling.combo >= 2)
{
fling.score += 10;
text = Instantiate(combo, transform.position + Vector3.down, Quaternion.Euler(0,0,0));
text.transform.SetParent(canvas.transform, true);
}
if (fling.lastTouched == "rightBumper" || fling.lastTouched == "leftBumper")
{
fling.score += 10;
text = Instantiate(bounce, transform.position + (Vector3.down * 2), Quaternion.Euler(0, 0, 0));
text.transform.SetParent(canvas.transform, true);
}
Any ideas on what’s causing this behavior?