I want to make a system where the player has a list that they can choose from (the location of items or secrets etc) and it will point in the general direction when accessing the menu along with a way to determine how close they are to the thing that they have selected. For example if there is an interactable that is hidden by accessing the menu they are able to find where about it is if they wanted to.
How would you go about creating a Compass/proximity system?
RPG Maker MV SupportIn order to get the distance, you can use either one of these script calls:
Just replace x2 and y2 with the XY coords of the event in question (or the corresponding script calls that return the coords, if the values should be dynamic...)
As for the general direction, this is a bit more complicated. What I did in my game is not the most efficient way, but it works. Essentially you need to check for 8 scenarios:
1. the event's X and Y are both higher than the player's
2. the event's X and Y are both lower than the player's
3. the event's X is lower than the player's and the Y is higher
4. the event's Y is lower than the player's and the X is higher
5. the event's X is equal to the player's and the Y is higher
6. the event's X is equal to the player's and the Y is lower
7. the event's Y is equal to the player's and the X is higher
8. the event's Y is equal to the player's and the X is lower
For each scenario, a different text or image is assigned to indicate the general direction.
As for the visual aspect of how to make all this appear on the screen - there are many plugins that help you set up customized menus and windows. For example, YEP Common Event Menu
$gameMap.distance($gamePlayer.x, $gamePlayer.y, x2, y2) - for rectilinear distanceMath.hypot($gameMap.deltaX($gamePlayer.x, x2), $gameMap.deltaY($gamePlayer.y, y2)) - for cartesian distanceJust replace x2 and y2 with the XY coords of the event in question (or the corresponding script calls that return the coords, if the values should be dynamic...)
As for the general direction, this is a bit more complicated. What I did in my game is not the most efficient way, but it works. Essentially you need to check for 8 scenarios:
1. the event's X and Y are both higher than the player's
2. the event's X and Y are both lower than the player's
3. the event's X is lower than the player's and the Y is higher
4. the event's Y is lower than the player's and the X is higher
5. the event's X is equal to the player's and the Y is higher
6. the event's X is equal to the player's and the Y is lower
7. the event's Y is equal to the player's and the X is higher
8. the event's Y is equal to the player's and the X is lower
For each scenario, a different text or image is assigned to indicate the general direction.
As for the visual aspect of how to make all this appear on the screen - there are many plugins that help you set up customized menus and windows. For example, YEP Common Event Menu
Just wanted to link you to this in case you didn’t know one already exists:
www.yanfly.moe
Proximity Compass (Olivia) - Yanfly.moe Wiki
Moghunter has a free compass plugin
mogplugins.wordpress.com
Rpg Maker MV
Battle Engine NameVersionUpdatedLinear Battle Systemv0.32b2021/05/01Chrono Enginev0.2b2021/05/01 Battle Plugins Name Version Updated Mog Aura Effect v3.0 2021/05/01 Mog ATB v0.3b 2021/05/01 Mog ATB…
Original thread: https://forums.rpgmakerweb.com/threads/how-would-you-go-about-creating-a-compass-proximity-system.157343/