- Home /
Issues with camera representation on a minimap
Working on an RTS, I'm having an issue with camera's representation display in the map UI ( the white square you see on the minimap ). I can't seem to move it accordingly.
![alt text][1] [1]: /storage/temp/111804-fuzz.jpg
Here is my code :
public void CameraRepresentationMove(Vector2 newCamPosition)
{
float infoX = miniMapTexture.width * newCamPosition.x / mapWidth ;
float infoY = miniMapTexture.height * newCamPosition.y / mapHeight ;
float parentScaleX = miniMap.transform.parent.localScale.x * miniMap.transform.localScale.x;
float parentScaleY = miniMap.transform.parent.localScale.y * miniMap.transform.localScale.y;
cameraRepresentation.transform.position = miniMap.transform.position + new Vector3(-parentScaleX * miniMap.sprite.texture.width / 2, -parentScaleY * miniMap.sprite.texture.height / 2, 0) + new Vector3(infoX * parentScaleX, (infoY + miniMap.sprite.texture.height)* parentScaleY, 1);
}
This should work, however, it doesn't seem to do it properly. Would anyone have any clue why ?
fuzz.jpg
(386.1 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612153219im_/https://answers.unity.com/themes/thub/images/avi.jpg)