-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputForward.gd
More file actions
26 lines (16 loc) · 947 Bytes
/
inputForward.gd
File metadata and controls
26 lines (16 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
extends StaticBody3D
@onready var _vp:SubViewport = $"../../../SubViewport"
func remap_range(value, InputA, InputB, OutputA, OutputB):
return(value - InputA) / (InputB - InputA) * (OutputB - OutputA) + OutputA
func _on_input_event(camera: Node, event: InputEvent, position: Vector3, normal: Vector3, shape_idx: int) -> void:
var pos = Vector2(round(remap_range(position.x, -0.713, 0.713, 0, 1024)),
round(remap_range(position.y, 0.09, 1.225, 910, 0)))
var ev:InputEvent = event.duplicate()
ev.position = pos
_vp.push_input(ev)
if ev is InputEventMouseMotion:
$"../../../armanims/mouse/MeshInstance3D2".position = (Vector3(remap_range(ev.position.x, 0, 1024, -0.5, 0.5), 0, remap_range(ev.position.y, 0, 910, -0.5, 0.5)))
func _on_mouse_entered() -> void:
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
func _on_mouse_exited() -> void:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE