+++ /dev/null
-extends Node3D
-class_name Scene
-
-
-@onready var player: Player = %Player
-@onready var debug: CanvasLayer = %debug
-@onready var version: String = ProjectSettings.get_setting("application/config/version")
-
-
-func _ready() -> void:
- debug.draw.add_vector(player, "velocity", 1, 1, Color(0,1,0,1))
- debug.draw.add_vector(player, "floor_normal", 1, 1, Color(0, 0, 1, 1))
- debug.draw.add_vector(player, "last_movement_direction", 1, 1, Color(1,0,0,1))
-
- debug.stats.add_property(self, "version", "")
- debug.stats.add_property(player, "state", "")
- debug.stats.add_property(player, "velocity", "length")
- debug.stats.add_property(player, "idle_time", "round")
-
-
-func _input(event: InputEvent) -> void:
- if event.is_action_pressed("left_click"):
- Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
- elif event.is_action_pressed("ui_cancel"):
- if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE:
- get_tree().quit()
- else:
- Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
+++ /dev/null
-uid://ccournv7m7l4y
[gd_scene load_steps=3 format=3 uid="uid://xtdsp4hhl70p"]
[ext_resource type="Script" uid="uid://jbyuxajvi3x1" path="res://main.gd" id="1_ig7tw"]
-[ext_resource type="PackedScene" uid="uid://cootj2rfyviyb" path="res://test.tscn" id="2_0xm2m"]
+[ext_resource type="PackedScene" uid="uid://cootj2rfyviyb" path="res://map/test.tscn" id="2_0xm2m"]
[node name="Main" type="Node"]
script = ExtResource("1_ig7tw")
--- /dev/null
+extends Node3D
+class_name Scene
+
+
+@onready var player: Player = %Player
+@onready var debug: CanvasLayer = %debug
+@onready var version: String = ProjectSettings.get_setting("application/config/version")
+
+
+func _ready() -> void:
+ debug.draw.add_vector(player, "velocity", 1, 1, Color(0,1,0,1))
+ debug.draw.add_vector(player, "floor_normal", 1, 1, Color(0, 0, 1, 1))
+ debug.draw.add_vector(player, "last_movement_direction", 1, 1, Color(1,0,0,1))
+
+ debug.stats.add_property(self, "version", "")
+ debug.stats.add_property(player, "state", "")
+ debug.stats.add_property(player, "velocity", "length")
+ debug.stats.add_property(player, "idle_time", "round")
+
+
+func _input(event: InputEvent) -> void:
+ if event.is_action_pressed("left_click"):
+ Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
+ elif event.is_action_pressed("ui_cancel"):
+ if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE:
+ get_tree().quit()
+ else:
+ Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
--- /dev/null
+uid://ccournv7m7l4y
--- /dev/null
+[gd_scene load_steps=4 format=3 uid="uid://iwl88y3l713o"]
+
+[ext_resource type="Material" uid="uid://dt1upwj08kd0w" path="res://map/grid_material.tres" id="1_w8p6k"]
+
+[sub_resource type="BoxMesh" id="BoxMesh_tgywu"]
+
+[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_w8p6k"]
+data = PackedVector3Array(-0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5)
+
+[node name="Cube" type="Node3D"]
+
+[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
+mesh = SubResource("BoxMesh_tgywu")
+surface_material_override/0 = ExtResource("1_w8p6k")
+
+[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
+
+[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"]
+shape = SubResource("ConcavePolygonShape3D_w8p6k")
--- /dev/null
+[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://dt1upwj08kd0w"]
+
+[ext_resource type="Texture2D" uid="uid://c8cfruu4iw5at" path="res://texture/grid.png" id="1_h25oc"]
+
+[resource]
+albedo_color = Color(0.46, 0.46, 0.46, 1)
+albedo_texture = ExtResource("1_h25oc")
+uv1_scale = Vector3(0.5, 0.5, 0.5)
+uv1_triplanar = true
+uv1_world_triplanar = true
--- /dev/null
+[gd_scene load_steps=4 format=3 uid="uid://b2qh1x7ulhhua"]
+
+[ext_resource type="Material" uid="uid://dt1upwj08kd0w" path="res://map/grid_material.tres" id="1_pbta4"]
+
+[sub_resource type="PrismMesh" id="PrismMesh_nxhg3"]
+size = Vector3(1, 1.78, 1)
+
+[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_pbta4"]
+data = PackedVector3Array(0, 0.89, 0.5, 0.5, -0.89, 0.5, -0.5, -0.89, 0.5, 0, 0.89, -0.5, -0.5, -0.89, -0.5, 0.5, -0.89, -0.5, 0, 0.89, 0.5, 0, 0.89, -0.5, 0.5, -0.89, 0.5, 0, 0.89, -0.5, 0.5, -0.89, -0.5, 0.5, -0.89, 0.5, 0, 0.89, -0.5, 0, 0.89, 0.5, -0.5, -0.89, -0.5, 0, 0.89, 0.5, -0.5, -0.89, 0.5, -0.5, -0.89, -0.5, -0.5, -0.89, 0.5, 0.5, -0.89, 0.5, -0.5, -0.89, -0.5, 0.5, -0.89, 0.5, 0.5, -0.89, -0.5, -0.5, -0.89, -0.5)
+
+[node name="Ramp" type="Node3D"]
+
+[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
+transform = Transform3D(-4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0, 0, 0)
+mesh = SubResource("PrismMesh_nxhg3")
+surface_material_override/0 = ExtResource("1_pbta4")
+
+[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
+
+[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"]
+shape = SubResource("ConcavePolygonShape3D_pbta4")
--- /dev/null
+[gd_scene load_steps=15 format=3 uid="uid://cootj2rfyviyb"]
+
+[ext_resource type="Script" uid="uid://ccournv7m7l4y" path="res://map/Scene.gd" id="1_8uh7m"]
+[ext_resource type="PackedScene" uid="uid://cchu1yltrhuk3" path="res://player/player.tscn" id="1_37kl0"]
+[ext_resource type="Script" uid="uid://dd3sep8kprktl" path="res://ux/debug_overlay.gd" id="2_ykrsh"]
+[ext_resource type="Script" uid="uid://mgg7ii0w4vod" path="res://ux/debug_stats.gd" id="3_g14j6"]
+[ext_resource type="Script" uid="uid://bocc5xwqtbkbb" path="res://ux/debug_draw_3d.gd" id="4_g14j6"]
+[ext_resource type="Material" uid="uid://dt1upwj08kd0w" path="res://map/grid_material.tres" id="6_v1i7h"]
+[ext_resource type="PackedScene" uid="uid://b2qh1x7ulhhua" path="res://map/ramp.tscn" id="7_5owfa"]
+[ext_resource type="PackedScene" uid="uid://iwl88y3l713o" path="res://map/cube.tscn" id="8_f4bcd"]
+
+[sub_resource type="Theme" id="Theme_g14j6"]
+default_base_scale = 2.0
+default_font_size = 20
+
+[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_37kl0"]
+sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
+ground_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
+
+[sub_resource type="Sky" id="Sky_8uh7m"]
+sky_material = SubResource("ProceduralSkyMaterial_37kl0")
+
+[sub_resource type="Environment" id="Environment_6uqi0"]
+background_mode = 2
+sky = SubResource("Sky_8uh7m")
+tonemap_mode = 2
+glow_enabled = true
+
+[sub_resource type="PlaneMesh" id="PlaneMesh_mf4mk"]
+size = Vector2(222, 222)
+
+[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_37kl0"]
+data = PackedVector3Array(111, 0, 111, -111, 0, 111, 111, 0, -111, -111, 0, 111, -111, 0, -111, 111, 0, -111)
+
+[node name="Test" type="Node3D"]
+script = ExtResource("1_8uh7m")
+
+[node name="debug" type="CanvasLayer" parent="."]
+unique_name_in_owner = true
+script = ExtResource("2_ykrsh")
+
+[node name="DebugStats" type="MarginContainer" parent="debug"]
+offset_right = 40.0
+offset_bottom = 40.0
+theme = SubResource("Theme_g14j6")
+theme_override_constants/margin_left = 20
+theme_override_constants/margin_top = 20
+theme_override_constants/margin_right = 20
+theme_override_constants/margin_bottom = 20
+script = ExtResource("3_g14j6")
+
+[node name="DebugDraw3D" type="Control" parent="debug"]
+layout_mode = 3
+anchors_preset = 0
+offset_right = 40.0
+offset_bottom = 40.0
+script = ExtResource("4_g14j6")
+
+[node name="Player" parent="." instance=ExtResource("1_37kl0")]
+unique_name_in_owner = true
+
+[node name="map" type="Node3D" parent="."]
+
+[node name="WorldEnvironment" type="WorldEnvironment" parent="map"]
+environment = SubResource("Environment_6uqi0")
+
+[node name="DirectionalLight3D" type="DirectionalLight3D" parent="map"]
+transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866026, -0.500003, 0.749999, -0.43301, 0, 0, 0)
+shadow_enabled = true
+
+[node name="MeshInstance3D" type="MeshInstance3D" parent="map"]
+mesh = SubResource("PlaneMesh_mf4mk")
+skeleton = NodePath("../..")
+surface_material_override/0 = ExtResource("6_v1i7h")
+
+[node name="StaticBody3D" type="StaticBody3D" parent="map/MeshInstance3D"]
+
+[node name="CollisionShape3D" type="CollisionShape3D" parent="map/MeshInstance3D/StaticBody3D"]
+shape = SubResource("ConcavePolygonShape3D_37kl0")
+
+[node name="Ramp" parent="map" instance=ExtResource("7_5owfa")]
+transform = Transform3D(-1.62606e-07, 0, -3.72, 0, 3.72, 0, 3.72, 0, -1.62606e-07, -0.137384, 0, 7.7898)
+
+[node name="Cube" parent="map" instance=ExtResource("8_f4bcd")]
+transform = Transform3D(2.54, 0, 0, 0, 2.54, 0, 0, 0, 2.54, -7.30192, 1.27, 5.19269)
+++ /dev/null
-extends Node3D
-class_name CameraHandler
-
-
-enum CameraInput {MOUSE, JOYSTICK}
-
-@export_range(1.0, 10.0) var camera_distance := 3.0
-@export_range(0.0, 1.0) var mouse_sensitivity := 0.15
-@export_range(0.0, 1.0) var mouse_sensitivity_x := 1.0
-@export_range(0.0, 1.0) var mouse_sensitivity_y := 0.5
-@export_range(0.0, 10.0) var joystick_sensitivity_x := 4.0
-@export_range(0.0, 10.0) var joystick_sensitivity_y := 2.0
-
-
-var camera_input_method := CameraInput.MOUSE
-var camera_input_direction := Vector2.ZERO
-var player_input_direction := Vector2.ZERO
-
-
-@onready var _input: InputHandler = %Input
-@onready var _spring: SpringArm3D = $spring
-
-
-# Called when the node enters the scene tree for the first time.
-func _ready() -> void:
- _spring.spring_length = camera_distance
-
-
-func _unhandled_input(event: InputEvent) -> void:
- # If user clicks on the window, capture the mouse and direct the camera with it
- if Input.get_mouse_mode() != Input.MOUSE_MODE_CAPTURED:
- return
-
- #_camera_input_direction *= mouse_sensitivity
- if event is InputEventMouseMotion:
- camera_input_method = CameraInput.MOUSE
- camera_input_direction = event.screen_relative * mouse_sensitivity
- elif event is InputEventJoypadMotion:
- # TODO: add these settings!
- camera_input_method = CameraInput.JOYSTICK
- camera_input_direction = _input.get_camera_input_direction()
- camera_input_direction *= Vector2(joystick_sensitivity_x, -joystick_sensitivity_y)
-
-
-# Called every frame. 'delta' is the elapsed time since the previous frame.
-func _process(delta: float) -> void:
- # vertical camera rotation
- rotation.x += camera_input_direction.y * mouse_sensitivity_y * delta
- rotation.x = clamp(rotation.x, -PI / 6, PI / 3)
-
- # horizontal camera rotation
- rotation.y -= camera_input_direction.x * mouse_sensitivity_x * delta
-
- # reset mouse movement vector if mouse input
- if camera_input_method == CameraInput.MOUSE:
- camera_input_direction = Vector2.ZERO
-
- # change spring length
- _spring.spring_length = lerp(
- _spring.spring_length, camera_distance, delta
- )
+++ /dev/null
-uid://c5mn28v6ujngk
+++ /dev/null
-extends Node
-class_name InputHandler
-
-
-func get_camera_input_direction() -> Vector2:
- return Input.get_vector(
- "camera-left", "camera-right", "camera-up", "camera-down"
- )
-
-
-func get_player_input() -> InputPacket:
- var p: InputPacket = InputPacket.new()
-
- p.movement_direction = Input.get_vector(
- "player-left", "player-right", "player-forward", "player-backward"
- )
- if p.movement_direction != Vector2.ZERO:
- p.actions.append("walk")
-
- if Input.is_action_just_pressed("player-dash"):
- p.actions.append("dash")
-
- if p.actions.is_empty():
- p.actions.append("idle")
-
- return p
+++ /dev/null
-uid://bspr3vafk6wi2
+++ /dev/null
-extends Node
-class_name InputPacket
-
-var movement_direction: Vector2 = Vector2.ZERO
-var actions: Array[String] = []
+++ /dev/null
-uid://cxsrxduew6xnc
+++ /dev/null
-extends Node
-class_name Move
-
-###
-# flags and variables here
-var player: Player
-var camera: Camera3D
-
-# enums are prioritized by order of list
-static var moves_priority: Dictionary = {
- "idle": 0,
- "walk": 1,
- "dash": 2
-}
-
-static func moves_priority_sort(a: String, b: String):
- return moves_priority[a] > moves_priority[b]
-
-###
-
-func should_enter(_input: InputPacket) -> String:
- print_debug("Function should_enter must be implemented in its child class!")
- return ""
-
-
-func update(_input: InputPacket, _delta: float):
- pass
-
-
-func on_enter_state():
- pass
-
-
-func on_exit_state():
- pass
+++ /dev/null
-uid://c886t1c86q0m6
+++ /dev/null
-extends Move
-class_name Dash
-
-
-func should_enter(input) -> String:
- input.actions.sort_custom(moves_priority_sort)
- return input.actions[0]
-
-
-func update(input: InputPacket, _delta: float):
- # Get the XZ input direction based on player's input relative to the camera
- var forward := camera.global_basis.z
- var right := camera.global_basis.x
- var move_direction := (
- forward * input.movement_direction.y + right * input.movement_direction.x
- ).normalized()
- move_direction.y = 0
-
- # TODO: check if new_pos is valid!
- var new_pos := player.last_movement_direction * player.dash_length
- player.global_position += new_pos
+++ /dev/null
-uid://bdiks0m7vsn5w
--- /dev/null
+extends Move
+class_name Fall
+
+
+func update(_input: InputPacket, delta: float):
+ player.velocity += player.get_gravity() * player.acceleration * delta
+ player.move_and_slide()
--- /dev/null
+uid://b0oj5iuvr8omo
+++ /dev/null
-extends Walk
-class_name Idle
-
-
-func update(input: InputPacket, delta: float):
- player.idle_time += delta
- super.update(input, delta)
-
-
-func on_enter_state():
- player.idle_time = 0.0
-
-
-func on_exit_state():
- player.idle_time = 0.0
+++ /dev/null
-uid://bv5k167ugxmso
--- /dev/null
+extends Node3D
+class_name CameraHandler
+
+
+enum CameraInput {MOUSE, JOYSTICK}
+
+@export_range(1.0, 10.0) var camera_distance := 3.0
+@export_range(0.0, 1.0) var mouse_sensitivity := 0.15
+@export_range(0.0, 1.0) var mouse_sensitivity_x := 1.0
+@export_range(0.0, 1.0) var mouse_sensitivity_y := 0.5
+@export_range(0.0, 10.0) var joystick_sensitivity_x := 4.0
+@export_range(0.0, 10.0) var joystick_sensitivity_y := 2.0
+
+
+var camera_input_method := CameraInput.MOUSE
+var camera_input_direction := Vector2.ZERO
+var player_input_direction := Vector2.ZERO
+
+
+@onready var _input: InputHandler = %Input
+@onready var _spring: SpringArm3D = $spring
+
+
+# Called when the node enters the scene tree for the first time.
+func _ready() -> void:
+ _spring.spring_length = camera_distance
+
+
+func _unhandled_input(event: InputEvent) -> void:
+ # If user clicks on the window, capture the mouse and direct the camera with it
+ if Input.get_mouse_mode() != Input.MOUSE_MODE_CAPTURED:
+ return
+
+ #_camera_input_direction *= mouse_sensitivity
+ if event is InputEventMouseMotion:
+ camera_input_method = CameraInput.MOUSE
+ camera_input_direction = event.screen_relative * mouse_sensitivity
+ elif event is InputEventJoypadMotion:
+ # TODO: add these settings!
+ camera_input_method = CameraInput.JOYSTICK
+ camera_input_direction = _input.get_camera_input_direction()
+ camera_input_direction *= Vector2(joystick_sensitivity_x, -joystick_sensitivity_y)
+
+
+# Called every frame. 'delta' is the elapsed time since the previous frame.
+func _process(delta: float) -> void:
+ # vertical camera rotation
+ rotation.x += camera_input_direction.y * mouse_sensitivity_y * delta
+ rotation.x = clamp(rotation.x, -PI / 6, PI / 3)
+
+ # horizontal camera rotation
+ rotation.y -= camera_input_direction.x * mouse_sensitivity_x * delta
+
+ # reset mouse movement vector if mouse input
+ if camera_input_method == CameraInput.MOUSE:
+ camera_input_direction = Vector2.ZERO
+
+ # change spring length
+ _spring.spring_length = lerp(
+ _spring.spring_length, camera_distance, delta
+ )
--- /dev/null
+uid://c5mn28v6ujngk
--- /dev/null
+extends Node
+class_name InputHandler
+
+
+func get_camera_input_direction() -> Vector2:
+ return Input.get_vector(
+ "camera-left", "camera-right", "camera-up", "camera-down"
+ )
+
+
+func get_player_input() -> InputPacket:
+ var p: InputPacket = InputPacket.new()
+
+ p.movement_direction = Input.get_vector(
+ "player-left", "player-right", "player-forward", "player-backward"
+ )
+ if p.movement_direction != Vector2.ZERO:
+ p.actions.append("walk")
+
+ if Input.is_action_just_pressed("player-dash"):
+ p.actions.append("dash")
+
+ if p.actions.is_empty():
+ p.actions.append("idle")
+
+ return p
--- /dev/null
+uid://bspr3vafk6wi2
--- /dev/null
+extends Node
+class_name InputPacket
+
+var movement_direction: Vector2 = Vector2.ZERO
+var actions: Array[String] = []
--- /dev/null
+uid://cxsrxduew6xnc
@onready var moves: Dictionary = {
"idle": $Idle,
"walk": $Walk,
- "dash": $Dash
+ "dash": $Dash,
+ "fall": $Fall
}
var current_move: Move
--- /dev/null
+extends Node
+class_name Move
+
+###
+# flags and variables here
+var player: Player
+var camera: Camera3D
+
+# enums are prioritized by order of list
+static var moves_priority: Dictionary = {
+ "idle": 0,
+ "walk": 1,
+ "dash": 2,
+ "fall": 100
+}
+
+static func moves_priority_sort(a: String, b: String):
+ return moves_priority[a] > moves_priority[b]
+
+###
+
+func should_enter(input: InputPacket) -> String:
+ if not player.is_on_floor():
+ input.actions.append("fall")
+ input.actions.sort_custom(moves_priority_sort)
+ return input.actions[0]
+
+
+func update(_input: InputPacket, _delta: float):
+ pass
+
+
+func on_enter_state():
+ pass
+
+
+func on_exit_state():
+ pass
--- /dev/null
+uid://c886t1c86q0m6
--- /dev/null
+extends Move
+class_name Dash
+
+
+func update(input: InputPacket, _delta: float):
+ # Get the XZ input direction based on player's input relative to the camera
+ var forward := camera.global_basis.z
+ var right := camera.global_basis.x
+ var move_direction := (
+ forward * input.movement_direction.y + right * input.movement_direction.x
+ ).normalized()
+ move_direction.y = 0
+
+ # TODO: check if new_pos is valid!
+ var new_pos := player.last_movement_direction * player.dash_length
+ player.global_position += new_pos
--- /dev/null
+uid://bdiks0m7vsn5w
--- /dev/null
+extends Walk
+class_name Idle
+
+
+func update(input: InputPacket, delta: float):
+ player.idle_time += delta
+ super.update(input, delta)
+
+
+func on_enter_state():
+ player.idle_time = 0.0
+
+
+func on_exit_state():
+ player.idle_time = 0.0
--- /dev/null
+uid://bv5k167ugxmso
--- /dev/null
+extends Move
+class_name Walk
+
+
+const skin_lean_limit := PI/4
+
+
+func update(input: InputPacket, delta: float):
+ player.velocity = get_new_velocity_from_input(input, delta)
+ player.move_and_slide()
+
+ # update skin rotation
+ var skin_target_angle := Vector3.BACK.signed_angle_to(
+ player.last_movement_direction,
+ Vector3.UP
+ )
+ player.skin.global_rotation.y = lerp_angle(
+ player.skin.global_rotation.y,
+ skin_target_angle,
+ player.rotation_speed * delta
+ )
+
+ # lean into player momentum just a little bit
+ player.skin.rotation.z = lerp_angle(
+ player.skin.rotation.z,
+ clamp(
+ player.last_movement_direction.signed_angle_to(
+ player.velocity, Vector3.UP
+ ) * player.velocity.length() * 0.08,
+ -skin_lean_limit, skin_lean_limit
+ ),
+ player.rotation_speed * delta * 0.25
+ )
+
+
+
+
+func get_new_velocity_from_input(input: InputPacket, delta: float) -> Vector3:
+ # Get the XZ input direction based on player's input relative to the camera
+ var forward := camera.global_basis.z
+ var right := camera.global_basis.x
+ var movement_direction := (
+ forward * input.movement_direction.y + right * input.movement_direction.x
+ ).normalized()
+ movement_direction.y = 0
+
+ # save off last movement direction
+ if movement_direction.length() > 0.2:
+ player.last_movement_direction = movement_direction
+
+ # if we're not stuck, then it's okay to set the velocity
+ player.floor_normal = player.get_floor_normal()
+ player.ground_slope_input = (PI / 2) - player.velocity.angle_to(player.floor_normal)
+ var new_velocity = player.velocity.move_toward(
+ movement_direction * (player.walk_speed + player.ground_slope_input * player.walk_speed),
+ player.acceleration * delta
+ )
+
+ return new_velocity
--- /dev/null
+uid://cqurhmxam2nl0
@export_group("Movement")
@export var walk_speed := 8.0
@export var dash_length := 10.0
-@export var air_speed := 3.0
@export var acceleration := 20.0
@export var rotation_speed := 10.0
@export var idle_timeout := 5.0
+
var idle_time := 0.00
var last_movement_direction := Vector3.ZERO
var state := ""
var floor_normal := Vector3.ZERO
var ground_slope_input := 0.0
-@onready var _input: InputHandler = %Input
-@onready var _model: PlayerModel = %Model
+@onready var input: InputHandler = %Input
+@onready var model: PlayerModel = %Model
+@onready var skin: AnimatedSkin = %skin
func _physics_process(delta: float) -> void:
- var input_pkt := _input.get_player_input()
- _model.update(input_pkt, delta)
+ var input_pkt := input.get_player_input()
+ model.update(input_pkt, delta)
-[gd_scene load_steps=10 format=3 uid="uid://cchu1yltrhuk3"]
+[gd_scene load_steps=11 format=3 uid="uid://cchu1yltrhuk3"]
[ext_resource type="PackedScene" uid="uid://dvkx3t15l7mfb" path="res://skin/prototype_skin.tscn" id="1_4flbx"]
[ext_resource type="Script" uid="uid://dcv34jq0jett0" path="res://player/player.gd" id="1_onrkg"]
-[ext_resource type="Script" uid="uid://bspr3vafk6wi2" path="res://player/InputHandler.gd" id="3_g1dw6"]
-[ext_resource type="Script" uid="uid://c5mn28v6ujngk" path="res://player/CameraHandler.gd" id="3_yw30f"]
+[ext_resource type="Script" uid="uid://bspr3vafk6wi2" path="res://player/input/InputHandler.gd" id="3_g1dw6"]
+[ext_resource type="Script" uid="uid://c5mn28v6ujngk" path="res://player/input/CameraHandler.gd" id="3_yw30f"]
[ext_resource type="Script" uid="uid://bwox6frn7fmgt" path="res://player/model.gd" id="5_qjkh3"]
-[ext_resource type="Script" uid="uid://bv5k167ugxmso" path="res://player/idle.gd" id="6_g6k8r"]
-[ext_resource type="Script" uid="uid://cqurhmxam2nl0" path="res://player/walk.gd" id="7_rgyib"]
-[ext_resource type="Script" uid="uid://bdiks0m7vsn5w" path="res://player/dash.gd" id="8_hg6s5"]
+[ext_resource type="Script" uid="uid://bv5k167ugxmso" path="res://player/moves/idle.gd" id="6_g6k8r"]
+[ext_resource type="Script" uid="uid://cqurhmxam2nl0" path="res://player/moves/walk.gd" id="7_rgyib"]
+[ext_resource type="Script" uid="uid://bdiks0m7vsn5w" path="res://player/moves/dash.gd" id="8_hg6s5"]
+[ext_resource type="Script" uid="uid://b0oj5iuvr8omo" path="res://player/fall.gd" id="9_hg6s5"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_sh265"]
[node name="Dash" type="Node" parent="Model"]
script = ExtResource("8_hg6s5")
+
+[node name="Fall" type="Node" parent="Model"]
+script = ExtResource("9_hg6s5")
+metadata/_custom_type_script = "uid://c886t1c86q0m6"
+++ /dev/null
-extends Move
-class_name Walk
-
-
-func should_enter(input) -> String:
- input.actions.sort_custom(moves_priority_sort)
- return input.actions[0]
-
-
-func update(input: InputPacket, delta: float):
- player.velocity = get_new_velocity_from_input(input, delta)
- player.move_and_slide()
-
-
-func get_new_velocity_from_input(input: InputPacket, delta: float) -> Vector3:
- # Get the XZ input direction based on player's input relative to the camera
- var forward := camera.global_basis.z
- var right := camera.global_basis.x
- var movement_direction := (
- forward * input.movement_direction.y + right * input.movement_direction.x
- ).normalized()
- movement_direction.y = 0
-
- # save off last movement direction
- if movement_direction.length() > 0.2:
- player.last_movement_direction = movement_direction
-
- # if we're not stuck, then it's okay to set the velocity
- player.floor_normal = player.get_floor_normal()
- player.ground_slope_input = (PI / 2) - player.velocity.angle_to(player.floor_normal)
- var new_velocity = player.velocity.move_toward(
- movement_direction * (player.walk_speed + player.ground_slope_input * player.walk_speed),
- player.acceleration * delta
- )
-
- return new_velocity
+++ /dev/null
-uid://cqurhmxam2nl0
+++ /dev/null
-[gd_scene load_steps=14 format=3 uid="uid://cootj2rfyviyb"]
-
-[ext_resource type="Script" uid="uid://ccournv7m7l4y" path="res://Scene.gd" id="1_8uh7m"]
-[ext_resource type="PackedScene" uid="uid://cchu1yltrhuk3" path="res://player/player.tscn" id="1_37kl0"]
-[ext_resource type="Texture2D" uid="uid://c8cfruu4iw5at" path="res://texture/grid.png" id="2_6uqi0"]
-[ext_resource type="Script" uid="uid://dd3sep8kprktl" path="res://ux/debug_overlay.gd" id="2_ykrsh"]
-[ext_resource type="Script" uid="uid://mgg7ii0w4vod" path="res://ux/debug_stats.gd" id="3_g14j6"]
-[ext_resource type="Script" uid="uid://bocc5xwqtbkbb" path="res://ux/debug_draw_3d.gd" id="4_g14j6"]
-
-[sub_resource type="Theme" id="Theme_g14j6"]
-default_base_scale = 2.0
-default_font_size = 20
-
-[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_37kl0"]
-sky_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
-ground_horizon_color = Color(0.662243, 0.671743, 0.686743, 1)
-
-[sub_resource type="Sky" id="Sky_8uh7m"]
-sky_material = SubResource("ProceduralSkyMaterial_37kl0")
-
-[sub_resource type="Environment" id="Environment_6uqi0"]
-background_mode = 2
-sky = SubResource("Sky_8uh7m")
-tonemap_mode = 2
-glow_enabled = true
-
-[sub_resource type="PlaneMesh" id="PlaneMesh_mf4mk"]
-size = Vector2(222, 222)
-
-[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_37kl0"]
-albedo_color = Color(0.46, 0.46, 0.46, 1)
-albedo_texture = ExtResource("2_6uqi0")
-uv1_scale = Vector3(60, 60, 60)
-uv1_world_triplanar = true
-
-[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_37kl0"]
-data = PackedVector3Array(111, 0, 111, -111, 0, 111, 111, 0, -111, -111, 0, 111, -111, 0, -111, 111, 0, -111)
-
-[node name="Test" type="Node3D"]
-script = ExtResource("1_8uh7m")
-
-[node name="debug" type="CanvasLayer" parent="."]
-unique_name_in_owner = true
-script = ExtResource("2_ykrsh")
-
-[node name="DebugStats" type="MarginContainer" parent="debug"]
-offset_right = 40.0
-offset_bottom = 40.0
-theme = SubResource("Theme_g14j6")
-theme_override_constants/margin_left = 20
-theme_override_constants/margin_top = 20
-theme_override_constants/margin_right = 20
-theme_override_constants/margin_bottom = 20
-script = ExtResource("3_g14j6")
-
-[node name="DebugDraw3D" type="Control" parent="debug"]
-layout_mode = 3
-anchors_preset = 0
-offset_right = 40.0
-offset_bottom = 40.0
-script = ExtResource("4_g14j6")
-
-[node name="Player" parent="." instance=ExtResource("1_37kl0")]
-unique_name_in_owner = true
-
-[node name="map" type="Node3D" parent="."]
-
-[node name="WorldEnvironment" type="WorldEnvironment" parent="map"]
-environment = SubResource("Environment_6uqi0")
-
-[node name="DirectionalLight3D" type="DirectionalLight3D" parent="map"]
-transform = Transform3D(-0.866024, -0.433016, 0.250001, 0, 0.499998, 0.866026, -0.500003, 0.749999, -0.43301, 0, 0, 0)
-shadow_enabled = true
-
-[node name="MeshInstance3D" type="MeshInstance3D" parent="map"]
-mesh = SubResource("PlaneMesh_mf4mk")
-skeleton = NodePath("../..")
-surface_material_override/0 = SubResource("StandardMaterial3D_37kl0")
-
-[node name="StaticBody3D" type="StaticBody3D" parent="map/MeshInstance3D"]
-
-[node name="CollisionShape3D" type="CollisionShape3D" parent="map/MeshInstance3D/StaticBody3D"]
-shape = SubResource("ConcavePolygonShape3D_37kl0")