3D Objective System

Godot Version

4.6.3-stable

Question

I am also working on a 3D game called Polycast, and it is meant to be a RPG. For any RPG, of course, there must be quests.

So, the first problem I thought of was “if the player is facing away from the objective, how do I tell them where it is? Even if the player is looking at (or close to) the objective, how do I tell them where on-screen it is?”

So my question is “How do I implement an objective/quest system like that of World of Warcraft?”

Thank you!

You’re asking two entirely different questions.
To answer your first question, how to show the position of something in 3D space, you can use
get_global_transform_with_canvas

Your second question is incredibly vague, and there’s no single answer to it. There are many, many different systems you’d need to create to make a quest system, I recommend looking up some guides for each part, start by simply creating a Resource that holds data about a quest, or list of quests. Then write functions that can add or remove / modify quests etc…

Facing towards or away from P.O.I.

if character and POI are 3D nodes:

var character_to_poi: Vector3 = poi.global_position - character.global_position
var direction_to_poi = character_to_poi.normalized()
var camera_facing_direction: Vector3 = camera.global_transform.basis.z

# BASIC TRIGONOMETRY: DOT = COSINE(A,B) * LENGTH(A) * LENGTH(B)
# SINCE A AND B ARE NORMALIZED, DOT = COS(A,B) * 1 * 1 = COS(A,B)
# CAMERA ALIGNMENT IS THAT COSINE.
var camera_alignment_factor: Vactor3 = direction_to_poi.dot(camera_facing_direction)

# If cosine between camera view and line from character to POI is under 0.5
# (that's a 60-degree cone), then show a visual cue pointing towards it 
if camera_alignment_factor < 0.5:
  poi_hint.show()
else:
  poi_hint.hide()

run this on _process() or _physics_process() and hint visibility will update every frame. I presume your hint will be labeled 2D arrows overlaid on a 3D world viewport, in which case you can use Sprite3D and label3D nodes as poi_hint. Tweak that 0.5 number closer to 1.0 for a tighter visibility cone or closer to 0 for a wider, more lenient definition of “still looking at it”. Values below 0 mean the POI is somewhere 90 to 180 degrees aligned, thus behind the character

I should have thought of dot products as a way to tell whether a node is visible on screen. Thank you! I’ll work on my own way of showing a directional hint (the POI is to your left, etc.).

There’s a demo if you want to check: