Hi. I’m trying to create a minimap in my game. And I ran into some rotation problem. We are talking about the rotation of the player’s image on the minimap. So I want the image on the minimap to point in the same direction as the player object in the scene. However, I can’t do that. I tried different ways but all failed. I suspect there may be a problem with the axis difference between the Scene and the UI elements, but I’m not sure. Does anyone have any idea how to help me?
If anyone has ever had a similar problem, here is the solution. A friend helped me with this
Vector2 v = new Vector2(Object.forward.x, Object.forward.z).normalized * -1;
float rot = Vector2.SignedAngle(Vector2.up, v);
UIelement.transform.rotation = Quaternion.Euler(0, 0, rot);