Hi all.
I am trying to code something like “enemy hit” effect. To start, I try to make a text that floats under the enemy. However, the position of the text is far from the object and moves in different direction as the enemy moves. Any explanation for this? The project is very simple: a camera, a plane and the moving enemy.
Code in the enemy’s script:
void OnGUI(){
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
GUI.Box(new Rect(pos.x, pos.y, 30, 30), "Hit");
}