← Pixel Dreamer Studio

Radar blips that turn with the player

Undo only the player's turn around Y, draw X and Z, and keep far enemies on the rim.

Take the offset from the player to each enemy, undo only the player's turn with d.rotated(Vector3.UP, -player.global_rotation.y), and draw Vector2(d.x, d.z) scaled to the radar, so the player's forward, -Z, points up. In our Godot 4.7 test, blips taken straight from global X and Z put an enemy 10 m straight ahead on the left of the radar once the player had turned 90 degrees left. The script kept it at the top, 41 px up on a 256 px radar that reaches 30 m.

The code

Add a Control with the same position and size as the radar picture, next to it rather than inside it, and attach this. Set player to the player, or to the camera in a first-person game, and add every enemy to the enemies group. blip_offset() gives where a blip goes, in pixels from the centre, if you would rather move icons than draw circles.

extends Control
## Draws enemy blips on a round radar. Up on the radar is where the player faces, and blips turn as the player turns.
## Put it over the radar picture with the same position and size, as a sibling, not a child of a spinning radar.

@export var player: Node3D  # the player, or the camera in a first-person game
@export var range_m := 30.0  # metres from the centre to the rim
@export var group := "enemies"  # every enemy is in this group
@export var blip_color := Color(1.0, 0.25, 0.2)
@export var blip_radius := 4.0


func _process(_delta: float) -> void:
	queue_redraw()


func radar_radius() -> float:
	return minf(size.x, size.y) * 0.5 - blip_radius


func blip_offset(world_pos: Vector3) -> Vector2:
	var d := world_pos - player.global_position
	d = d.rotated(Vector3.UP, -player.global_rotation.y)  # undo only the turn: looking up or down does not move blips
	var p := Vector2(d.x, d.z) * (radar_radius() / range_m)  # the player's forward, -Z, points up on the radar
	return p.limit_length(radar_radius())  # enemies out of range sit on the rim, not outside the radar


func _draw() -> void:
	if player == null:
		return
	var centre := size * 0.5
	for e in get_tree().get_nodes_in_group(group):
		if e is Node3D:
			draw_circle(centre + blip_offset(e.global_position), blip_radius, blip_color)

What we measured

A radar 256 px wide and 30 m to the rim, so a blip sits at most 124 px from the centre. We read the red pixels the script drew as well as the numbers. Two runs gave the same results.

Why the blips end up in the wrong place

World X and Z do not know which way the player faces, so blips from them make a map that always points the same way, while the player expects ahead to be up. The whole inverse transform does turn with the player, but it also undoes looking up and down, which tips the offset and makes enemies look closer. A flat radar only needs the turn around Y, and in Godot's default rotation order global_rotation.y is that turn by itself, even on a camera that also looks up or down.

Radar pictures that spin a sweep line usually rotate the whole node, and a child Control rotates with its parent, so blips placed inside it go round with the sweep.

What to change

Radar pictures to put it on: the Godot 4 Ready Kit is 9 products in one bundle, including the full VFX Collection and 124 Sci-Fi HUD Elements with 6 radars that spin a sweep, plus rings, reticles, target locks and gauges as Godot 4 scenes. The HUD pack is also sold on its own: 124 Sci-Fi HUD Elements.

Tested in Godot 4.7 with the Compatibility renderer.

Ready-made: Godot 4 Ready Kit is 9 products in one bundle: the full VFX Collection plus 124 Sci-Fi HUD Elements with 6 spinning radars, toon, ink wash, skies, PBR and tools.

More how-tos: UI and HUD