add collisions and player gravity
This commit is contained in:
parent
b4faa5d35b
commit
0e6540daf5
@ -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"]
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user