Added Dart Physics
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
extends MeshInstance3D
|
||||
|
||||
@onready var camera = get_node("Camera3D")
|
||||
@onready var area = get_node("../../../Dart")
|
||||
|
||||
func _input(event):
|
||||
if Input.is_action_just_pressed("leftClick"):
|
||||
print(camera.ray_cast().position)
|
||||
|
||||
if camera.ray_cast() != null and Input.is_action_pressed("midleclic"):
|
||||
var mousepos = get_viewport().get_mouse_position()
|
||||
var origin = camera.projectray_origin(mousepos)
|
||||
var end = camera.project_ray_normal(mousepos)
|
||||
var depth = origin.distence_to(area.global_position)
|
||||
var final_position = origin + end * depth
|
||||
area.global_position=final_position
|
||||
Reference in New Issue
Block a user