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
|
|
@ -2,6 +2,7 @@ extends CharacterBody3D
|
|||
|
||||
@onready var animated_mesh: Node3D = %GobotSkin
|
||||
@onready var camera: Camera3D = %Camera3D
|
||||
@onready var camera_root: Node3D = $CameraRoot
|
||||
|
||||
## State
|
||||
@export var battle_state: Enums.BattleState = Enums.BattleState.NOT_IN_BATTLE
|
||||
|
|
@ -15,6 +16,7 @@ const JUMP_VELOCITY: float = 4.5
|
|||
const ROTATION_SPEED: float = 12.0
|
||||
const CAMERA_ROTATION_SPEED: float = 1.3
|
||||
const MANUAL_CAMERA_ROTATION_SPEED: float = 5.0
|
||||
var camera_smoothing_factor: float = 0.1
|
||||
|
||||
func _ready() -> void:
|
||||
# Set the global reference to the player
|
||||
|
|
@ -24,7 +26,6 @@ func _ready() -> void:
|
|||
# HACK: This should rather be connected from a global SignalManager or SignalBus
|
||||
get_viewport().get_tree().get_root().find_child("JoystickPanel", true, false).connect("on_interact", interact)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# If the player is in a battle, handle it via start_battle and then handle_battle
|
||||
if battle_state != Enums.BattleState.NOT_IN_BATTLE:
|
||||
|
|
@ -45,10 +46,6 @@ func _physics_process(delta: float) -> void:
|
|||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
# Manual camera rotation
|
||||
var camera_input_dir : Vector2 = Input.get_vector("joystick_right_left", "joystick_right_right", "joystick_right_left", "joystick_right_right")
|
||||
$CameraRoot.rotation.y += camera_input_dir.x * MANUAL_CAMERA_ROTATION_SPEED * delta
|
||||
|
||||
# Get the input direction and handle the movement / deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var input_dir : Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue