added proper touch controls and put terrain in a separate file
This commit is contained in:
parent
3be1d07acd
commit
bdfcc74491
10 changed files with 77 additions and 35 deletions
27
ui/touch_controls.gd
Normal file
27
ui/touch_controls.gd
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
extends Node
|
||||
class_name TouchControls
|
||||
|
||||
@export var touch_controls_enabled: bool = true
|
||||
@export_range(0.0, 0.01, 0.0001) var touch_sensitivity: float = 0.01
|
||||
|
||||
@export var tilt_limit_high: float = deg_to_rad(75)
|
||||
@export var tilt_limit_low: float = deg_to_rad(20)
|
||||
|
||||
@onready var _camera: Camera3D = %Camera3D
|
||||
@onready var _camera_pivot: Node3D = %CameraRoot
|
||||
|
||||
var target_rotation: Vector2 = Vector2(0, 0)
|
||||
@export_range(0.01, 1.0, 0.01) var smoothing_factor: float = 0.1
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventScreenDrag:
|
||||
#_camera_pivot.rotation.x -= event.screen_relative.y * touch_sensitivity
|
||||
target_rotation.x -= event.screen_relative.y * touch_sensitivity
|
||||
target_rotation.y += -event.screen_relative.x * touch_sensitivity
|
||||
|
||||
target_rotation.x = clampf(target_rotation.x, -tilt_limit_high, tilt_limit_low)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_camera_pivot.rotation.x = lerp(_camera_pivot.rotation.x, target_rotation.x, smoothing_factor)
|
||||
_camera_pivot.rotation.y = lerp(_camera_pivot.rotation.y, target_rotation.y, smoothing_factor)
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue