godot_experiments/experiments/test_3d.gd

12 lines
300 B
GDScript

extends Node3D
@onready var camera = $Camera3D
func _ready():
var sp = get_screen_position($LCB)
print("3D物体在屏幕上的位置: ", sp)
func get_screen_position(mesh_instance):
var global_position = mesh_instance.global_transform.origin
return camera.unproject_position(global_position)