I have some rotation problem for my minimap icons.
Basically I attach a script on my jet to create at start a minimap icon gameobject with a SpriteRenderer and the specific sprite that gets parented on it.
Now keep in mind that I use SpriteRenderer for the minimap icon, so I need to rotate it +90° local on the X-axis.
Because of the minimap icon is a child of the jet, it aligns its rotation with it, so if it sort of flips over, the icon itself is stretched in the RenderTexture minimap.
So, I am trying to rotate the minimap icon only on the Global Y, but how do I normalize the rotation of the jet to get the desired Y-angle? The jet.forward vector (Blue arrow) will give the right Y direction of the minimap icon, but how I convert this to a Global Y angle?
By stating this approach above, I want to update its rotation like this:
blipInstance.transform.eulerAngles = new Vector3(90f, ForwardToGlobalY(transform), 0f);
float ForwardToGlobalY(Transform t){
float targetY;
//Do calculation
return targetY;
}
↧