]> Untitled Git - knight.git/commitdiff
Getting the look and feel right
authorClifton Palmer <clifton.james.palmer@protonmail.com>
Tue, 19 Nov 2024 17:40:43 +0000 (19:40 +0200)
committerClifton Palmer <clifton.james.palmer@protonmail.com>
Tue, 19 Nov 2024 17:40:43 +0000 (19:40 +0200)
player/player.gd
player/player.tscn
test/block.tscn [new file with mode: 0644]
test/test.tscn

index 54b838e7ae210d2acdf0dbefbe3f442b6f958744..1c483fa4bf22e5c99ebf689c90e11c98b77b0a04 100644 (file)
@@ -5,13 +5,22 @@ extends CharacterBody3D
 
 
 const SPEED = 5.0
 
 
 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():
 
 
 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():
 
        # 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")
        # 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
        if direction:
                velocity.x = direction.x * SPEED
-               velocity.z = -direction.z * SPEED
+               velocity.z = direction.z * SPEED
+               _last_movement_direction = direction
        else:
        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())
 
        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()
        else:
                _skin.fall()
index ac16d4b706243aeccfc0fb5515b16d627fb94ee3..7d9c024c8a09473a2436b0389ce50f634563c12f 100644 (file)
@@ -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"]
 
 [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")
 
 [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"]
 [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"]
 
 [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 (file)
index 0000000..4d65109
--- /dev/null
@@ -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")
index 0e2999b138fd67fa2ed5b83fab35c74e958b0855..4e181aad2c2296371a4314e76cab4e51155e46f2 100644 (file)
@@ -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://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)
 
 [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="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)