20 lines
699 B
GDScript
20 lines
699 B
GDScript
extends Label3D
|
|
|
|
var campath = "/CollisionShape3D/Neck/Camera3D"
|
|
var labelpath = "/nameLabel"
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
pass # Replace with function body.
|
|
|
|
|
|
func _process(delta):
|
|
var cam_node = get_node(str(Global.selfTeddy) + campath)
|
|
var self_label = get_node(str(Global.selfTeddy) + labelpath)
|
|
var camera_position = cam_node.global_transform.origin
|
|
var direction = (camera_position - global_transform.origin).normalized()
|
|
var flipped_direction = -direction
|
|
var target_pos = global_transform.origin + flipped_direction + Vector3(0.01, 0.01, 0.01)
|
|
|
|
# Set the label's rotation to face the camera
|
|
look_at(target_pos, Vector3(0, 1, 0))
|