0 votes

I'm looking to create a radar minimap sort of thing that acts like a motion tracker from Aliens while also showing you your objective, it's a top down 2d shooter game, I've looked up tutorials but so far they've either been sort of like little tricks (Like making a copy of a map and showing it very small in the corner of your screen but that's not only too much effort as you'd have to either do some extra work recoding new ones every time, implement export vars, or some other third possible way to make it easy on yourself.) I just want a nice way of having one node I can drop in the canvas layer of any of my scenes that acts like a motion tracker and shows where your objective is relative to you, any help at all is appreciated.

Godot version 3.4
in Engine by (20 points)

1 Answer

+1 vote

There are two low effort versions of this that come to mind.

The lowest effort is adding a second viewport to your screen with a camera that's very high overhead. You'd have to figure out how to make your objective stand out, or how to hide anything that you didn't want to show in the map.

The second is more like an actual radar with no map, and with dots indicating the objective's proximity to the player. You can do this by finding the position of each objective relative to the player, scaling that down to fit your radar, and drawing all of that to your screen. The drawing can be done with sprites, texture_rects, or manually.

Here's some quick pseudo-code to help convey the idea:

var radar_center = Vector2(50, 50)  # position of the radar on screen
var radar_radius = 40
var radar_range = 500  # maximum distance the radar can "see"

for each objective:
    # get the position of the objective relative to the player
    # you might want to use global positions here
    var p = objective.position - player.position

    # check if objective is out of range
    var real_distance_to_player = p.length()
    if real_distance_to_player > radar_range:
        # if this objective is to too far away, skip it
        continue

    # scale the relative position to proportionally fit on the radar
    var position_on_radar = ((p / radar_range) * radar_radius)
    # move the position relative to the radar's center
    position_on_radar += radar_center

    draw_dot(position_on_radar)
by (272 points)

Thanks for your help

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.