diff --git a/Scenes/Main.tscn b/Scenes/Main.tscn index 000a2e7..36d7a66 100644 --- a/Scenes/Main.tscn +++ b/Scenes/Main.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://Scripts/Main.gd" id="1_2yjjx"] [ext_resource type="PackedScene" uid="uid://deff7lt34nj0h" path="res://Spaces/Dungeon.tscn" id="2_4gs22"] -[ext_resource type="PackedScene" uid="uid://d3e3a6xdwo2dp" path="res://Scenes/Player.tscn" id="3_eq7hn"] +[ext_resource type="PackedScene" uid="uid://b83k3b5x1wmyl" path="res://Scenes/Player.tscn" id="3_eq7hn"] [sub_resource type="Environment" id="Environment_pn2uj"] diff --git a/Scenes/Player.tscn b/Scenes/Player.tscn index fded525..28be13a 100644 --- a/Scenes/Player.tscn +++ b/Scenes/Player.tscn @@ -1,7 +1,11 @@ -[gd_scene load_steps=2 format=3 uid="uid://d3e3a6xdwo2dp"] +[gd_scene load_steps=3 format=3 uid="uid://b83k3b5x1wmyl"] [ext_resource type="Script" path="res://Scripts/Player.gd" id="1_m1g7d"] +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_pfjla"] +radius = 0.4 +height = 1.4 + [node name="Player" type="CharacterBody3D" node_paths=PackedStringArray("camera")] script = ExtResource("1_m1g7d") camera = NodePath("Pivot/Camera3D") @@ -9,3 +13,6 @@ camera = NodePath("Pivot/Camera3D") [node name="Pivot" type="Node3D" parent="."] [node name="Camera3D" type="Camera3D" parent="Pivot"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="."] +shape = SubResource("CapsuleShape3D_pfjla") diff --git a/Scripts/Main.gd b/Scripts/Main.gd index 1495afa..a8ec75f 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -3,7 +3,7 @@ extends Node3D func _ready(): add_child($Dungeon.generate_geometry()) - var spawn = $Dungeon.get_spawn() + var spawn: SpaceSpawn.Desc = $Dungeon.get_spawn() $Player.position = spawn.position $Player.position.y += 0.5 $Player.rotation = spawn.rotation diff --git a/Scripts/Player.gd b/Scripts/Player.gd index baa35fe..db80434 100644 --- a/Scripts/Player.gd +++ b/Scripts/Player.gd @@ -6,7 +6,8 @@ extends CharacterBody3D const VIEW_BOB_FREQUENCY = 8 const VIEW_BOB_AMPLITUDE = 0.03 -var speed := 2 +var gravity := 20.0 +var speed := 2.0 var turn_speed_sec := 0.1 var turn_degrees := 90 var view_bob_time := 0.0 # increased while velocity is not zero @@ -55,8 +56,7 @@ func _process(delta: float) -> void: func _physics_process(delta: float) -> void: - # TODO - #velocity.y += gravity * delta + velocity.y -= gravity * delta var final_velocity = _get_input() * speed velocity.x = final_velocity.x diff --git a/Scripts/Space/Space.gd b/Scripts/Space/Space.gd index 61dbd99..b6811fe 100644 --- a/Scripts/Space/Space.gd +++ b/Scripts/Space/Space.gd @@ -15,7 +15,7 @@ func generate_geometry() -> Node3D: for child in get_children(): if child is SpaceRegion: - var geometry = child.generate_geometry(self) + var geometry: MeshInstance3D = child.generate_geometry(self) root.add_child(geometry) return root diff --git a/Scripts/Space/SpaceRegion.gd b/Scripts/Space/SpaceRegion.gd index 15d519f..caf573d 100644 --- a/Scripts/Space/SpaceRegion.gd +++ b/Scripts/Space/SpaceRegion.gd @@ -56,6 +56,7 @@ func _generate_geometry(space: Space, looked_from_inside: bool) -> Node3D: if child is SpaceRegion: geometry.add_child(child._generate_geometry(space, not looked_from_inside)) + geometry.create_trimesh_collision() return geometry