Rotate the minimap?

I would like my mini map to rotate so that the character’s facing is always pointing up on the minimap.

The map is just single sprite image viewed through a circle so the image can move around to keep the character centered in the circle.

Another way of describing the functionality I want would be:
Imagine a paper with a pin in it; the paper can spin around the pin. But i want the paper to be able to slide past the pin while still having its rotation constrained to the pin location.

Or… imagine a lense on a satelite looking straight down at the map, it can move around in every direction but always rotates around the center of the lense.

I’ve been stuck on this for a week, looking in forum posts, experimenting, watching videos and I can’t get it, sooo here I am even though I expect every answer to just tell me not to do that :stuck_out_tongue:

Any help is appreciated, thanks :slight_smile:

Set minimap angle to angle of your player

1 Like

That causes the map to rotate around the map center instead of the center of the minimap circle

You should show what kind of minimap you have there

Now i think i get your minimap
Correct me if i am wrong
Your minimap FOR EXAMPLE
Is big rectangle or square lets say square 100x100
Where radius of your circle is 20 so 10px from center to the circle edge

And so you are showing different part of map at a time inside minimap circle?

I would assume idea would be to use distance between two positions to account offset from actual map center
OR angle between positions
These are expressions
You should test them out

I mean i think it would work i am not sure
IDK if you can rotate something by offset
Or you can rotate by angle of something that is offset

But these would be 2 things i would try

Now that i think of it there is also expression something along the lines angle from position
Maybe that is the key

Make sure the minimap and map are on different layers.

Can you screen shot the events that spin the minimap around? It may be something simple that’s causing the issue.

The issue is getting the mini map to move freely but only rotate around the center of the lense instead of the center of the map object. I can’t screenshot because i’ve tried about 15 different things and none of them worked: either the map rotates properly but cant move or it can move but doesn’t rotate properly. I just assumed something like this would be trivial and I was just missing something obvious but I guess I’m the first person to try this? Lol

At this point I’m brushing up on my trigonometry to just brute-force it.

Hello @Sage ,
If I understand your question, you have to change the rotation origin point.
Try with this command:


and let us know

That relocates the map object so its center is at the specified location.

Is this what you need?

I need the map to always rotate around the center of the minmap circle regardless of its position.

If there was a way to change the center of rotation of an object dynamically that would be exactly what i need, but I’ve found no way of doing that; I don’t think it is possible.

I did not test it i did not use it my knowledge is same as yours about it so if you can’t answer question about it then for sure i also can’t

BUIUUUUUT

This extension claims it can set center point of something
Sooooo

1 Like

What object is the minimap? How are you creating it? Can you share a screen snip of the events that update the minimap? All the answers so far are guesses because we have no idea how you are doing it.

You’re right.
I’m triing to write an example for you but it’s not easy. Sorry

Hi there! I’m guessing you’re looking for a minimap rotation similar to NFS U2 or maybe Vice City?
If so, here’s my attempt at replicating it.

What I did here was that I set a reference point object on the center of the main map, “RoomCenter”, used to get the relative location of the player object “CharPlayer”.
Then I also set up a player marker object on the minimap, “CharMini” for setting the relative location of the center of the minimap.
And another object, “PivotMini” which will be the makeshift center of the Minimap when it rotates.
On the computations, there’s a “+90” to the total angles, that’s to make the 12 o’clock as the main direction where the player is facing. By default 0 degrees is to the right, or at 3 o’clock.
Finally, the divisor “/2”, that’s the scale factor. So here the minimap is half the size of the main map.
Maybe someone might know how to optimize it or have a simpler way of doing it? idk. Also while testing, I noticed an occasional wobble while rotating… i don’t really know where that’s coming from, maybe the sprites I used or the math needs further tweaking or something…
So yeah, hope it helps.

I would assume wobble comes from events order
Every single time i had issue with text object flickering when changing text
For example i set it to display score variable
And it flickers as soon as score changes due getting new digit
For example when it switches fro 99 to 100
Look at my post here

You have there 2 gifs
Top gif have that issue as soon as new digit is added to string it flickers
It is due it is positioning itself based on length of string (since origin point is on the left)
And then it update position and so there is delay between how long string is now and when position is updated
I never can remember does position change action should be above or below text change action
But it is one way or another

And as you see that 2nd gif with negative numbers does not have that problem
I made it after figuring out why it is flickering

And so in your case i guess in one action you change angle or something
And other action that is above it updates it
And that is the problem

I simply suggest mess around with order of your actions/events
And it will be fixed

And i would care to ask
What does SIN do there?
I do not know what it does so what is the purpose of this expression and how it works??
Damn also what COS is cause i guess they are opposite of each other?

1 Like

Uh… I’m not that good with math, mind you, but from what I understand is that
SIN is used when computing for the Y value since the Y axis is assigned as the “opposite” side from the angle in question.
The X axis, on the other hand, is assigned as the “adjacent” side from said angle, so COS is used to compute for the X value.
From what little I’ve been able to retain from high school, SOH CAH TOA have been useful after all. lol. Oh and ToRad is used to convert them to radians but I believe you already know that.

So, anyway, in this particular setup, we use Cos and Sin to get the X and Y and coordinates for the minimap objects based on the angles and distances of the objects on the main map. Then we also have to account for the angle change for when the minimap rotates hence, PivotMini.Angle() is added to the equation. And of course, (for the sake of completion) the +90 to make the minimap face upwards, and the distance value / 2 to scale it down… uhm, yeah, I hope that didn’t sound too “lecturey”.

To be honest, I still have a bit of trouble wrapping my head around it sometimes. Like that +90, at first I thought it should have been +270 (or -90) due to the rotation of the angles in the engine. But then I guess, it must be due to me setting the RoomCenter as reference point instead of the CharPlayer. I thought of switching it up but then I’m afraid it might affect the other values. And you know what they say, “If it ain’t broke, don’t fix it.” lol.

Alright, so I also did what you suggested and changed the order of events. I found that putting the PivotMini rotation on first, that got rid of the occasional wobble. Also I just put them all in one event. I’m currently not yet using this rotating minimap thing, but I do happen to be planning to implement it in one of my projects at a future time. I guess that’s one less headache for future me, lol.
Thanks!

HAHAHA thx but
I do not ask for math explanation
I ask for explanation/example in human language
I understand from what you wrote as little as from all wiki articles i did read

You really need to give me bare bones example why it is needed here
Like assume i am dumbest user you ever meet

I mean i do understand part that “in this situation we use this and in other situation we use that”
I do not understand why and what it does

I know how ToRad works sadly
I also am making minimap yet mine is dynamically drawing itself with shape painter

Do you think same magic would by possible with my minimap?
I mean i bet it would
Yet my minimap do not use any kind of objects
All is drawn from positions of objects in actual game
So i have no idea how to translate what you did there to my minimap
By now i upgraded it a lot from what is in the post there
(i am still making example out of it)

I would assume i would need to draw crap based on rotation of player
And here i have same problem as OP
How to account for X and Y offset

For example this is all the crap i use draw objects from weapons object group
And so as you see on minimap skeleton throw axe
Axe spins even on minimap

This version is drawing crap based on camera position
I have also version which draws crap based on player position
If i would be able to adapt your idea into my minimap
I wonder would logic be the same
Where i calculate everything based on position of camera or player and just add angle into the mix

If you care for challenge i could provide updated version zip

And more or less it looks like

Sorry, I am a bit at a loss how to explain in human language… I’ve been with the lizards for too long… kidding… but dumbest? really? You’re like one of these pros on here. And looking at your events… that’s a tad advanced for me… alright, you’re definitely pulling my leg. Though I could probably get that… give me a couple of months or so. Maybe six or seven just to be sure. lol.

But okay, I’ll bite. And also for the sake of others who might stumble into this post. Though, I still don’t really know how to explain the thing without getting into the maths, but I’ll do my best to simplify it… I hope… And here, I thought a bit of illustration might help.

AnglesExplanation2

So first the question, why is it needed? Imagine a player object on top down map, has a crosshair, 100 pixels away. The player turns 45 degrees to the right. Would the X and Y coordinates of the crosshair be just 100 for both? or -100 if he turns 45 degrees left? Obviously it doesn’t work that way. Computations have to be made. After making proper computations it’s x=70.71 and y=-70.71. Witchcraft! Oh and that’s only if the player is at coordinates(0,0). What if the player moves? What if the angle is 50 degrees? etc… Panic mode! There’s a way! Calm… More maths! Panic mode!

AnglesExplanation

  1. This should be what it looks like to the engine. There’s a reference point (R) and a target point. We know the X,Y coordinates of R. We don’t know that of the target. That’s what we’re trying to find out. But we know the distance (H) between the R and the target. We also know the angle it would make on the main map.

  2. Is what it should look like in the minimap. Exactly the same thing but smaller, distance is scaled down. So the angle used is exactly the same as from the main map, but applied to it’s own reference point and target and with the distance calculated to be smaller using a scale factor.

  3. Is how X and Y axis are usually referenced.

  4. That Y axis reference is the same value if it were to make a triangle. We just imagine it to be right there as the opposite side of the angle.

  5. Now we have us a triangle. Everything needed to compute for the X and Y of the target is right there. The angle from the reference point, the hypotenuse(H, distance), the adjacent side of the triangle (X), and the opposite side (Y).
    The computations, of course, involves the use of Sin and Cos. Sin = opposite/hypotenuse (SOH); Cos = adjacent/hypotenuse (CAH);

  6. What happens when it spins or the target and/or the reference changes position? The angle would change and perhaps the distance also, but the numbers we need are still there. Same concept applies. We just recompute using the new values, then we are able to account for the X and Y offset.

Though now that I think about it, the simplest might be to think of Cos just as a way to get X, and Sin as a way to get Y. Does it help to know how they do it? I honestly don’t know. Although it’s probably better to know than to just use them blindly. But like I said, i’m not really that good in math so don’t take my word for it.
So there it is. Thank you for coming to my ted talk… lol.

Anyway, your project, I’m not quite sure how you intend to use rotation on your minimap. But if it’s not going to rotate, just a minimap on a fixed plane, yeah, the concept should work pretty much the same. And you wouldn’t need an extra angle calculation to account for the spin.
Here’s an event from one of my projects that involves a fixed radar:

For each axis X and Y, it’s got just one angle to account for together with the distance (the 180 is because I switched the reference and target again. I gotta start paying attention to these things. lol)

So your project drawing stuff as it goes along, yeah, I think it can work too. Do forgive me though, I still haven’t wrapped my head around all that stuff in your events. heh… But in the event I provided for OP, I noticed that it’s possible to not actually have to use the PivotMini object. Just get the raw calculations and apply them directly to the event.

So yeah, I suppose your project could do likewise. Like, drawing is being done on coordinates (28, 42) there’s the x and y, then use those coordinates to get an angle and distance from a reference point, apply to minimap. Though I have to admit, making theories is easy enough, but when actually creating the events for them… yeah, not so much.

Man, I hope I didn’t make my essay too long…

1 Like

Longer it is better someone can filter which info will help achieve what he want

And for me as simple as cos for X and sin for Y is all i needed to know here
I do not understand what exactly it does
I just needed to know that cos gets X and sin gets Y
Yet i do understand most of what you wrote but in the end rest is just like I WILL KNOW and that’s all
This is not kind of knowledge i need to have
Think of it as i know i need to add water to a cake to not burn it
I do not need to know what water is doing exactly and how

But damn you that gave me very good idea of what to do and how regarding minimap rotation

AND just for record
I know how to fix pc replace motherboard elements how to diagnose which resistor on motherboard is broken
YET i have no idea how to fix anything in a car
Just because i have knowledge in one aspect do not believe even for a moment i am pro or whatever
I understand some stuff while in other areas i am as green as new users
For example i am almost 2 years here yet i have no idea how to handle physics
I was able to get coins bounce off the ground by trying every possible combination in physics properties
And that is end of my knowledge
Yet i see ppl that use gdevelop for less than month and are making bloody ropes/chains out of physics WTF?
And who is more pro now?

On other hand i also answer questions on discord of ppl that are here far longer than me and made a lot more advanced/complex games than i could imagine

THX to you for that knowledge
I just realized my minimap should automatically work with rotation
I just need to add something to calculate based on rotation

You see in that screenshot from my events you trying to find some ultra cryptic advanced crap
If you look closely there are 4 variables GX Y W H as in Xpos Ypos Height Width
And every single math there is calculated based on that
So even so formula is long if you would change for example GX+blablabla/2*something whatever
You would get for example just 10 as a number

But i think i will manage from here on
THX A LOT what you wrote really helps

1 Like

Well, there it is. You just simplified it best. Cos to get X and Sin to get Y. And here I was thinking a bit more info was needed. lol.

And yeah, it’s true, for everyone, there’s always room for learning and growing. Reminds me of those movies where for all Tony Stark’s genius, along comes this kid, Peter Parker dishing out seemingly simple ideas that Tony could never dream of. Ah I digress. But it is just like you said about those new guys that take to gdevelop like a duck in water. I say, “I’m not even mad. That’s amazing!” Those guys are probably genius level all the way up there.

Anyway, for now I’m just happy my little contribution to the vast collection of knowledge in these pages are found helpful while at the same time I continue to learn new stuff as well. So yeah, you’re welcome and thank you also for your ideas. I intend to continue to peruse the events of your minimap that you shared, I think I get the gist of it, though I’m pretty sure that learning will get much, much faster when I find one of my projects needing it. Heh.

Now we wait and see if anything in this discussion hopefully solves OP’s question. Cheers!