From: Clifton Palmer Date: Tue, 19 Nov 2024 17:40:43 +0000 (+0200) Subject: Getting the look and feel right X-Git-Url: http://git.purplebirdman.com/knight.git/commitdiff_plain/8eac100b8bfd471e2057544c95f355affd249dda?hp=14955fc67047f5f1fde5c1cb2570ca5e6de5c439 Getting the look and feel right --- diff --git a/player/player.gd b/player/player.gd index 54b838e..1c483fa 100644 --- a/player/player.gd +++ b/player/player.gd @@ -5,13 +5,22 @@ extends CharacterBody3D const SPEED = 5.0 -const JUMP_VELOCITY = 4.5 +const JUMP_VELOCITY = 4.5 * 3 +const FALL_SPEED = 2.0 + + +var _last_movement_direction := Vector3.FORWARD + + +func _input(event: InputEvent) -> void: + if event.is_action_released("ui_accept"): + velocity.y = 0 func _physics_process(delta: float) -> void: # Add the gravity. if not is_on_floor(): - velocity += get_gravity() * delta + velocity += get_gravity() * FALL_SPEED * delta # Handle jump. if Input.is_action_just_pressed("ui_accept") and is_on_floor(): @@ -20,18 +29,19 @@ func _physics_process(delta: float) -> void: # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. 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() + 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 + velocity.z = direction.z * SPEED + _last_movement_direction = direction else: - velocity.x = move_toward(velocity.x, 0, SPEED) - velocity.z = move_toward(velocity.z, 0, SPEED) + velocity.x = 0 + velocity.z = 0 move_and_slide() if is_on_floor(): _skin.forward(velocity.length()) - _skin.global_rotation.y = Vector3.FORWARD.signed_angle_to(direction, Vector3.UP) + _skin.global_rotation.y = Vector3.BACK.signed_angle_to(_last_movement_direction, Vector3.UP) else: _skin.fall() diff --git a/player/player.tscn b/player/player.tscn index ac16d4b..7d9c024 100644 --- a/player/player.tscn +++ b/player/player.tscn @@ -1,11 +1,19 @@ -[gd_scene load_steps=4 format=3 uid="uid://chtr62feiltax"] +[gd_scene load_steps=5 format=3 uid="uid://chtr62feiltax"] [ext_resource type="PackedScene" uid="uid://bgmpst4q8lyw2" path="res://skin/the-knight.tscn" id="1_3dem8"] [ext_resource type="Script" path="res://player/player.gd" id="1_lnm7a"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ew3kx"] -radius = 0.279573 -height = 0.942401 +radius = 0.202782 +height = 0.857531 + +[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_tmjox"] +dof_blur_far_enabled = true +dof_blur_far_distance = 5.0 +dof_blur_far_transition = 3.0 +dof_blur_near_enabled = true +dof_blur_near_distance = 4.0 +dof_blur_amount = 0.2 [node name="Player" type="CharacterBody3D"] script = ExtResource("1_lnm7a") @@ -20,7 +28,8 @@ transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) [node name="camera-pivot" type="Node3D" parent="."] [node name="SpringArm3D" type="SpringArm3D" parent="camera-pivot"] -transform = Transform3D(-1, 0, -8.74228e-08, -2.26267e-08, 0.965926, 0.258819, 8.44439e-08, 0.258819, -0.965926, 0, 0.443057, 0) -spring_length = 3.0 +transform = Transform3D(-1, 1.56557e-08, -1.45851e-07, -2.26267e-08, 0.965926, 0.258819, 1.44933e-07, 0.258819, -0.965926, 0, 0.443057, 0) +spring_length = 5.0 [node name="Camera3D" type="Camera3D" parent="camera-pivot/SpringArm3D"] +attributes = SubResource("CameraAttributesPractical_tmjox") diff --git a/test/block.tscn b/test/block.tscn new file mode 100644 index 0000000..4d65109 --- /dev/null +++ b/test/block.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=3 format=3 uid="uid://dbthgkok84ru0"] + +[sub_resource type="BoxMesh" id="BoxMesh_sv1vj"] + +[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_3ttn7"] +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="Block" type="Node3D"] + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.485735, 0) +mesh = SubResource("BoxMesh_sv1vj") + +[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"] +shape = SubResource("ConcavePolygonShape3D_3ttn7") diff --git a/test/test.tscn b/test/test.tscn index 0e2999b..4e181aa 100644 --- a/test/test.tscn +++ b/test/test.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=8 format=3 uid="uid://bvydwnbie3pv4"] +[gd_scene load_steps=9 format=3 uid="uid://bvydwnbie3pv4"] [ext_resource type="PackedScene" uid="uid://chtr62feiltax" path="res://player/player.tscn" id="1_ytdba"] +[ext_resource type="PackedScene" uid="uid://dbthgkok84ru0" path="res://test/block.tscn" id="2_8u8xb"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_ohmka"] sky_top_color = Color(0.0360979, 0.133006, 0.175678, 1) @@ -51,3 +52,21 @@ surface_material_override/0 = SubResource("StandardMaterial3D_87x6o") [node name="CollisionShape3D" type="CollisionShape3D" parent="ground/plane/StaticBody3D"] shape = SubResource("ConcavePolygonShape3D_73kmu") + +[node name="Block" parent="ground" instance=ExtResource("2_8u8xb")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.30582, 0, 0.134318) + +[node name="Block2" parent="ground" instance=ExtResource("2_8u8xb")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.94243, 1.91616, 0.268636) + +[node name="Block3" parent="ground" instance=ExtResource("2_8u8xb")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.315662, -4.76837e-07, -3.10105) + +[node name="Block4" parent="ground" instance=ExtResource("2_8u8xb")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.899326, 0, -2.69083) + +[node name="Block5" parent="ground" instance=ExtResource("2_8u8xb")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.8697, 0, 3.31299) + +[node name="Block6" parent="ground" instance=ExtResource("2_8u8xb")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.79621, 4.76837e-07, 3.0765)