I’m trying to make a radar like thing where all the enemies are shown relative to my player on a display. (just like in the old elite)
I have it all working properly until I rotate the player. I need to calculate the new coordinates of the enemies when the player rotates. for example: (assume 2d)
The player is at 0,0 and a enemy is at 0,6 so in front of the player and showing up in front of the player on the radar. now I rotate the player left 90 degrees, I need to turn the enemy real world coordinate into a new one based on the players new rotation so it shows up to the right of the player on the radar so in this example the coordinates would be 6,0
The easiest way to do such thing is to actually just add a extra camera who looks at your player top-down (Who is a child of your player so that it rotates along). And make it render a different layer, and put all minimap/radar associated things on that layer. This is probably easier then calculating and positioning everything yourself, as you can simply add something to your prefabs in that layer, and as long as your main camera doesn’t render that layer, only your minimap will be able to see it.
As for you question. What you wan’t is the local position to the player. You can get that using transform.InverseTransformPoint.
The result of that would be a position relative to the player.