summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-29 20:16:56 +0530
committerBobby <[email protected]>2026-03-29 20:16:56 +0530
commit65a143a0871c35989b7c7ea6723d39a0585c089e (patch)
treefcd193f823c30feeeec139d248cded2b7c817eef
parenta3e669824509bf3c4f8bdf0f52cbf025be66a4f1 (diff)
downloadechoes-of-vaelun-65a143a0871c35989b7c7ea6723d39a0585c089e.tar.xz
echoes-of-vaelun-65a143a0871c35989b7c7ea6723d39a0585c089e.zip
feat: player movement and camera setup
-rw-r--r--game/project.godot37
-rw-r--r--game/scenes/player/player.tscn22
-rw-r--r--game/scenes/world/world.tscn38
-rw-r--r--game/scripts/player/player.gd45
-rw-r--r--game/scripts/player/player.gd.uid1
5 files changed, 142 insertions, 1 deletions
diff --git a/game/project.godot b/game/project.godot
index 949e671..a58efc1 100644
--- a/game/project.godot
+++ b/game/project.godot
@@ -11,7 +11,7 @@ config_version=5
[application]
config/name="Echoes of Vaelun"
-run/main_scene="uid://c5dscglj3fwm3"
+run/main_scene="uid://bl88h8a5rl8b4"
config/features=PackedStringArray("4.6", "Forward Plus")
config/icon="res://icon.svg"
@@ -19,6 +19,41 @@ config/icon="res://icon.svg"
Nakama="*uid://b6tpsu78xwjth"
+[input]
+
+ui_left={
+"deadzone": 0.5,
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
+, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
+, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
+]
+}
+ui_right={
+"deadzone": 0.5,
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
+, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
+, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
+, null, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
+]
+}
+ui_up={
+"deadzone": 0.5,
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
+, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
+, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
+]
+}
+ui_down={
+"deadzone": 0.5,
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
+, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
+, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
+]
+}
+
[physics]
3d/physics_engine="Jolt Physics"
diff --git a/game/scenes/player/player.tscn b/game/scenes/player/player.tscn
new file mode 100644
index 0000000..538318c
--- /dev/null
+++ b/game/scenes/player/player.tscn
@@ -0,0 +1,22 @@
+[gd_scene format=3 uid="uid://d04hu1q8te62b"]
+
+[ext_resource type="Script" uid="uid://cgppr6hihbtfr" path="res://scripts/player/player.gd" id="1_8afob"]
+
+[sub_resource type="CapsuleMesh" id="CapsuleMesh_x7p2l"]
+
+[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_8afob"]
+
+[node name="Player" type="CharacterBody3D" unique_id=947962190]
+script = ExtResource("1_8afob")
+
+[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1224402165]
+mesh = SubResource("CapsuleMesh_x7p2l")
+
+[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=523270179]
+shape = SubResource("CapsuleShape3D_8afob")
+
+[node name="SpringArm3D" type="SpringArm3D" parent="." unique_id=2117008477]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0)
+spring_length = 4.0
+
+[node name="Camera3D" type="Camera3D" parent="SpringArm3D" unique_id=182180429]
diff --git a/game/scenes/world/world.tscn b/game/scenes/world/world.tscn
new file mode 100644
index 0000000..62e90cd
--- /dev/null
+++ b/game/scenes/world/world.tscn
@@ -0,0 +1,38 @@
+[gd_scene format=3 uid="uid://bl88h8a5rl8b4"]
+
+[ext_resource type="PackedScene" uid="uid://d04hu1q8te62b" path="res://scenes/player/player.tscn" id="1_dphjl"]
+
+[sub_resource type="PlaneMesh" id="PlaneMesh_sl2e5"]
+size = Vector2(100, 100)
+
+[sub_resource type="BoxShape3D" id="BoxShape3D_1fp7r"]
+size = Vector3(100, 0.1, 100)
+
+[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_6m72w"]
+
+[sub_resource type="Sky" id="Sky_v5dby"]
+sky_material = SubResource("ProceduralSkyMaterial_6m72w")
+
+[sub_resource type="Environment" id="Environment_t5ptc"]
+background_mode = 2
+sky = SubResource("Sky_v5dby")
+
+[node name="World" type="Node3D" unique_id=2025247588]
+
+[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=1702302743]
+
+[node name="GroundMesh" type="MeshInstance3D" parent="StaticBody3D" unique_id=431720177]
+mesh = SubResource("PlaneMesh_sl2e5")
+
+[node name="GroundCollision" type="CollisionShape3D" parent="StaticBody3D" unique_id=1967947790]
+shape = SubResource("BoxShape3D_1fp7r")
+
+[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=145236090]
+transform = Transform3D(0.70710677, 0.49999997, -0.49999997, 0, 0.70710677, 0.70710677, 0.70710677, -0.49999997, 0.49999997, 0, 0, 0)
+shadow_enabled = true
+
+[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1948458948]
+environment = SubResource("Environment_t5ptc")
+
+[node name="Player" parent="." unique_id=947962190 instance=ExtResource("1_dphjl")]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.3556347, 0.99040365, -0.31166124)
diff --git a/game/scripts/player/player.gd b/game/scripts/player/player.gd
new file mode 100644
index 0000000..b3ef737
--- /dev/null
+++ b/game/scripts/player/player.gd
@@ -0,0 +1,45 @@
+extends CharacterBody3D
+
+const SPEED = 5.0
+const JUMP_VELOCITY = 4.5
+const MOUSE_SENSITIVITY = 0.003
+const CAMERA_MIN_PITCH = -0.4
+const CAMERA_MAX_PITCH = 0.6
+
+@onready var spring_arm = $SpringArm3D
+@onready var camera = $SpringArm3D/Camera3D
+
+var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
+var camera_pitch = 0.0
+
+func _ready():
+ Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
+
+func _unhandled_input(event):
+ if event is InputEventMouseMotion:
+ rotate_y(-event.relative.x * MOUSE_SENSITIVITY)
+ camera_pitch -= event.relative.y * MOUSE_SENSITIVITY
+ camera_pitch = clamp(camera_pitch, CAMERA_MIN_PITCH, CAMERA_MAX_PITCH)
+ spring_arm.rotation.x = camera_pitch
+
+ if event.is_action_pressed("ui_cancel"):
+ Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
+
+func _physics_process(delta):
+ if not is_on_floor():
+ velocity.y -= gravity * delta
+
+ if Input.is_action_pressed("ui_accept") and is_on_floor():
+ velocity.y = JUMP_VELOCITY
+
+ var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
+ var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
+
+ if direction:
+ velocity.x = direction.x * SPEED
+ velocity.z = direction.z * SPEED
+ else:
+ velocity.x = move_toward(velocity.x, 0, SPEED)
+ velocity.z = move_toward(velocity.z, 0, SPEED)
+
+ move_and_slide()
diff --git a/game/scripts/player/player.gd.uid b/game/scripts/player/player.gd.uid
new file mode 100644
index 0000000..336ae30
--- /dev/null
+++ b/game/scripts/player/player.gd.uid
@@ -0,0 +1 @@
+uid://cgppr6hihbtfr