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
|
||||
1
ui/touch_controls.gd.uid
Normal file
1
ui/touch_controls.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dgjc3dw1gbiyg
|
||||
2
ui/ui.gd
2
ui/ui.gd
|
|
@ -8,7 +8,7 @@ signal on_game_continued
|
|||
@onready var main_menu: Control = $MainMenu
|
||||
@onready var ingame_controls: Control = $IngameControls
|
||||
@onready var ingame_menu: Control = $IngameMenu
|
||||
@onready var camera_control_area : Control = $CameraControlArea
|
||||
#@onready var camera_control_area : Control = $CameraControlArea
|
||||
@onready var save_ui : Control = $SaveUI
|
||||
@onready var battle_ui : Control = $BattleUI
|
||||
|
||||
|
|
|
|||
12
ui/ui.tscn
12
ui/ui.tscn
|
|
@ -1,7 +1,6 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://b5y7pdfe6ougf"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://b5y7pdfe6ougf"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bhajdnao0awhr" path="res://ui/ui.gd" id="1_fkttd"]
|
||||
[ext_resource type="Script" uid="uid://cp2jtkql0gaci" path="res://ui/ingame_controls/camera_controls.gd" id="1_x56x6"]
|
||||
[ext_resource type="PackedScene" uid="uid://dt00rjsodtady" path="res://ui/main_menu/main_menu.tscn" id="3_tcmm8"]
|
||||
[ext_resource type="PackedScene" uid="uid://1anjhvi173g3" path="res://ui/ingame_controls/ingame_controls.tscn" id="4_likk0"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbvbnrcjatkrb" path="res://ui/ingame_menu/ingame_menu.tscn" id="5_qjqu1"]
|
||||
|
|
@ -10,15 +9,6 @@
|
|||
[node name="UI" type="CanvasLayer"]
|
||||
script = ExtResource("1_fkttd")
|
||||
|
||||
[node name="CameraControlArea" type="Control" parent="."]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_x56x6")
|
||||
|
||||
[node name="SaveUI" type="Control" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue