after looking at the effect in the vid, i don't think you need an object.
once you define your Objective Coords (X#,Y#,Z#), take a look at the
GetScreenXFrom3D() and
GetScreenYFrom3D() commands.
if the resultant ...
From3D X/Y Coords are on the screen (or close to it, taking the size of the sprite/text object into account), you'll have a point of reference for which to position your sprite and/or text object.
this isn't pretty but i think you'll get the point:
// Project: ObjectiveSprite
// Created: 2020-03-21
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "ObjectiveSprite" )
SetWindowSize( 1080, 720, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1080, 720 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
GLOBAL ObjX# as Float
GLOBAL ObjY# as Float
GLOBAL ObjZ# as Float
Marker = CreateText("TEST") `CreateSprite(0) : SetSpriteSize(Marker,64,64) : SetSpriteColor(Marker,255,0,0,128)
SetTextAlignment(Marker,1)
SetTextSize(Marker,32)
SetCameraRotation(1,0,0,0)
do
if GetRawMouseRightPressed() = 1 then SetCameraLookAt(1,ObjX#,ObjY#,ObjZ#,0) `face objective
CamX# = GetCameraX(1) : CamY# = GetCameraY(1) : CamZ# = GetCameraZ(1) : CamAngleY# = GetCameraAngleY(1)
LookLR = GetRawMouseX()-LastPointerX `MOUSELOOK
If LookLR <> 0
RotateCameraLocalY(1,LookLR)
LastPointerX = GetRawMouseX()
Endif
LookUD = GetRawMouseY()-LastPointerY
If LookUD <> 0
RotateCameraLocalZ(1,LookUD)
LastPointerY = GetRawMouseY()
Endif
Move = GetRawKeyState(38)-GetRawKeyState(40) `Up/Down to Move
If Move <> 0
MoveCameraLocalZ(1,Move)
EndIf
ThisDistance# = SQRT( (CamX#-ObjX#)^2 + (CamY#-ObjY#)^2 + (CamZ#-ObjZ#)^2 )
ScreenX# = GetScreenXFrom3D(ObjX#, ObjY#, ObjZ#) : ScreenY# = GetScreenYFrom3D(ObjX#, ObjY#, ObjZ#)
If IsOnScreen(ScreenX#,ScreenY#) = 1
SetTextPosition(Marker,ScreenX#,ScreenY#)
SetTextString(Marker, STR(ThisDistance#,2))
SetTextVisible(Marker,1)
Else
SetTextVisible(Marker,0)
Endif
if ThisDistance# < 50 then NextObjective()
Sync()
loop
Function NextObjective()
ObjX# = Random(200,500)
ObjY# = 0.0
ObjZ# = Random(200,500)
EndFunction
Function IsOnScreen(X#,Y#)
If X# > -1 and X# < 1080 and Y# > -1 and Y# < 720
Result = 1
Else
Result = 0
Endif
EndFunction Result
hope that helps