Initial commit
This commit is contained in:
commit
d7302501f0
16 changed files with 225 additions and 0 deletions
7
src/draggable_camera.gd
Normal file
7
src/draggable_camera.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
extends Camera3D
|
||||
|
||||
const SENSITIVITY = 0.05
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if Input.is_action_pressed("drag_camera") and event is InputEventMouseMotion:
|
||||
global_position += get_ * Vector3(event.relative.x,event.relative.y,0)
|
||||
1
src/draggable_camera.gd.uid
Normal file
1
src/draggable_camera.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://crjao0jjv5yqs
|
||||
23
src/draggable_object.gd
Normal file
23
src/draggable_object.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
extends Area3D
|
||||
|
||||
|
||||
var mouse_in: bool = false
|
||||
var dragged: bool = false
|
||||
|
||||
func _mouse_enter() -> void:
|
||||
mouse_in = true
|
||||
|
||||
func _mouse_exit() -> void:
|
||||
mouse_in = false
|
||||
dragged = false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if dragged == false:
|
||||
return
|
||||
var camera: Camera3D = get_viewport().get_camera_3d()
|
||||
var new_position: Vector3 = camera.project_position(get_viewport().get_mouse_position(),(-camera.basis.z).dot(camera.to_local(global_position)))
|
||||
global_position = new_position
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if mouse_in and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
dragged = true if event.pressed else false
|
||||
1
src/draggable_object.gd.uid
Normal file
1
src/draggable_object.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bjnv2g1ni0525
|
||||
Loading…
Add table
Add a link
Reference in a new issue