- Edited
Hi everyone,
I cannot to find the good operation to size the box that show the camera view in a minimap, can you help me ?
I should have something around 520 x 290 but the result i have aren't near and too far to this values.
Hi everyone,
I cannot to find the good operation to size the box that show the camera view in a minimap, can you help me ?
I should have something around 520 x 290 but the result i have aren't near and too far to this values.
The goal, if you don't understand, is the little box in the minimap must ajust according to the size of the map (97 x 97).
If i have for example 128 x 96, the little box will be differant about the size.
Hello Lethn,
I'm not sure the Tween will help me: The little box in the minimap, which represents the camera, haven't a initial value in the beginning, because it depends of the size of the map.
But in the case of i want to "zoom in/out" the camera, during the game, Tween is indeed useful to adjust the minimap's box size. But it's not i need actually.
This box have to be sized when the game process started, it will not change during the game, just moved. So the "unknow initial value" is what i looking for. The value of 520 x 290 is what i found manually and visually but it's not accurate.
In that case all you'd need to do is remove the tween option and just have the size static? I would follow the tutorial to get the results you're looking for then edit to your liking.
Create a new Node2D and name it "Minimap".
Set the position of the Minimap node to where you want the minimap to appear on-screen. You can do this by changing the X and Y values in the Inspector panel.
Add a new Viewport node as a child of the Minimap node.
In the Inspector panel, set the Viewport's Width and Height properties to 520 and 290, respectively, to match the size you want for the minimap.
Under the Viewport node, add a new Camera node and name it "MinimapCamera".
Set the Camera's Transform property to the position where you want the camera to look on your scene. This should be the center of your minimap.
Set the Camera's Zoom property to an appropriate value that will show the area you want in the minimap. An optimal value can vary depending on your game's scale and the size of the area you want to show.
Finally, add any other nodes such as sprites, labels, or other objects you want to appear on your minimap.
I found it:
First, i need to get the "ratio" between the map and the minimap size (map size/minimap size)
Then, i divide this result with the physical screen size (1920 x 1080 /(map size/minimap size))
I divide this result by 2, because i must set the begin and the end of the little box in the minimap
And i add finally a value of 20, because the minimap container do 820 x 820 (for borders), the texture inside do 800 x 800.
And i reach the theorical result (520 x 290).
var worldToMinimap = mapWorld/rect_size
var minimapBox = OS.get_screen_size()/worldToMinimap
box.set_begin(Vector2(-minimapBox.x/2-10, -minimapBox.y/2-10))
box.set_end(Vector2(minimapBox.x/2+10, minimapBox.y/2+10))