I’m current working on a 3D space flight sim. I’m trying to have an objective system where you can set a waypoint with a Vector3 and it’ll display a texture when you look at that position. So right now it displays at the position I input but if you turn the camera 180 degrees the texture will show up at the same point on the screen even though the position I passed in is now behind the camera. Any advice is welcome.
here is my function:
void SetWayPoint(Vector3 target)
{
Vector2 position = Camera.main.WorldToScreenPoint(target);
Vector2 screenPos = GUIUtility.ScreenToGUIPoint(new Vector2(position.x, position.y));
GUI.DrawTexture(new Rect(screenPos.x - ObjectiveLocator.width/2, Screen.height - screenPos.y - ObjectiveLocator.height/ 2, ObjectiveLocator.width, ObjectiveLocator.height), ObjectiveLocator);
}