From 5978a900173648a44a0d279441992c8b382daff9 Mon Sep 17 00:00:00 2001 From: derek Date: Fri, 17 Jan 2025 16:54:03 -0600 Subject: [PATCH] added dof blur on time slowdown --- assets/mac_10.tscn | 4 ++-- assets/player.tscn | 8 +++++++- assets/revolver_1.tscn | 2 +- scenes/enemy_working_scene.tscn | 5 ++++- scripts/player.gd | 17 +++++++++++++++-- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/assets/mac_10.tscn b/assets/mac_10.tscn index 766d5ef..d339f86 100644 --- a/assets/mac_10.tscn +++ b/assets/mac_10.tscn @@ -680,7 +680,7 @@ script = ExtResource("2_tskiy") gun_name = "Mac 10" gun_icon = ExtResource("3_p1hxc") gun_info = ExtResource("4_ex2eo") -fov_zoom_amt = 5.0 +fov_zoom_amt = 15.0 recoil_amount = Vector3(0.02, 0.05, 0.05) max_ammo = 20 bullet_damage = 2 @@ -702,7 +702,7 @@ audio_empty = NodePath("Audio/Empty") audio_reload = NodePath("Audio/Reload") [node name="mac10" parent="." index="0"] -transform = Transform3D(-1.08301e-06, -8.05098e-08, -0.3, -0.0225093, 0.299154, 9.76371e-10, 0.299154, 0.0225093, -1.086e-06, -0.00876398, 0.0748287, -0.0557729) +transform = Transform3D(-1.08301e-06, -8.05094e-08, -0.3, -0.0225093, 0.299154, 9.76756e-10, 0.299154, 0.0225093, -1.086e-06, -0.00876398, 0.0748287, -0.0557729) cast_shadow = 0 lod_bias = 10.0 mesh = SubResource("ArrayMesh_pcg38") diff --git a/assets/player.tscn b/assets/player.tscn index 28f5bdf..dee4ef6 100644 --- a/assets/player.tscn +++ b/assets/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=34 format=3 uid="uid://drwae3loscbw7"] +[gd_scene load_steps=35 format=3 uid="uid://drwae3loscbw7"] [ext_resource type="Script" path="res://scripts/player.gd" id="1_x7wms"] [ext_resource type="Script" path="res://scripts/recoil.gd" id="3_405jc"] @@ -35,6 +35,11 @@ height = 2.03547 radius = 0.509802 height = 1.19106 +[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_vhypf"] +dof_blur_far_enabled = true +dof_blur_near_enabled = true +dof_blur_amount = 0.3 + [sub_resource type="FastNoiseLite" id="FastNoiseLite_vupcx"] noise_type = 0 frequency = 0.05 @@ -116,6 +121,7 @@ script = ExtResource("3_405jc") [node name="Camera3D" type="Camera3D" parent="Head/Recoil"] transform = Transform3D(1, -8.30784e-09, 2.09548e-09, 7.50333e-12, 1, -6.0536e-09, 0, 0, 1, 1.29921e-05, -0.0445602, -0.00379455) cull_mask = 1048573 +attributes = SubResource("CameraAttributesPractical_vhypf") current = true [node name="WeaponHolder" type="Node3D" parent="Head/Recoil/Camera3D"] diff --git a/assets/revolver_1.tscn b/assets/revolver_1.tscn index f284477..f875051 100644 --- a/assets/revolver_1.tscn +++ b/assets/revolver_1.tscn @@ -1343,7 +1343,7 @@ gun_name = ".44 Galore" gun_icon = ExtResource("3_nl201") ammo_type = 1 fire_mode = 1 -fov_zoom_amt = 15 +fov_zoom_amt = 35 recoil_amount = Vector3(0.125, 0.1, 0.1) max_ammo = 6 bullet_damage = 5 diff --git a/scenes/enemy_working_scene.tscn b/scenes/enemy_working_scene.tscn index 83a76ce..313ab53 100644 --- a/scenes/enemy_working_scene.tscn +++ b/scenes/enemy_working_scene.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://dsnddbrlqkav2"] +[gd_scene load_steps=22 format=3 uid="uid://dsnddbrlqkav2"] [ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_laua1"] [ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_poauc"] @@ -15,6 +15,7 @@ [ext_resource type="PackedScene" uid="uid://by3n26uvps8tb" path="res://assets/water_tower.tscn" id="14_yn32s"] [ext_resource type="PackedScene" uid="uid://cgo4qyul7ix5p" path="res://assets/ladder.tscn" id="15_bsva3"] [ext_resource type="PackedScene" uid="uid://cdpxctwwi12j" path="res://assets/ladder_collision_check.tscn" id="15_vb271"] +[ext_resource type="PackedScene" uid="uid://bj1y0fbjtul4a" path="res://post_processing.tscn" id="16_p7sg0"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_w6vpl"] sky_top_color = Color(0.623488, 0.812575, 0.900791, 1) @@ -229,3 +230,5 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12.7187, -0.500688, -37.3549 [node name="Ladder" parent="." instance=ExtResource("15_bsva3")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12.7245, -0.170555, -36.0291) + +[node name="PostProcessing" parent="." instance=ExtResource("16_p7sg0")] diff --git a/scripts/player.gd b/scripts/player.gd index caa2c92..8e4d91f 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -18,7 +18,7 @@ const STAMINA_DRAIN = 20 const HEAD_TILT_AMT = .06 const BOB_FREQ = 1.7 const BOB_AMP = 0.1 -const ADS_POS = Vector3(0,-.05,-.45) +const ADS_POS = Vector3(0,-.05,-.3) #JOYSTICK SETTINGS const JOYSTICK_SENSITIVITY = .06 @@ -463,6 +463,7 @@ func _physics_process(delta): if level_control.health <= 0: level_control.die() + focus_on_target() joypad_look(delta) aim_down_sights(delta) flashlight_toggle() @@ -545,7 +546,9 @@ func aim_down_sights(delta): gun.position = lerp(gun.position,ADS_POS,delta * 10 / Engine.time_scale) else: gun.position = lerp(gun.position, weapon_start_pos,delta * 2) - camera.fov = lerp(camera.fov,BASE_FOV - float(gun.fov_zoom_amt),(delta * 5)/Engine.time_scale) + camera.fov = lerp(camera.fov,BASE_FOV - float(gun.fov_zoom_amt),(delta * 4)/Engine.time_scale) + else: + gun.position = lerp(gun.position, weapon_start_pos,delta * 10) func grab_moveable(body): holster_gun(true) @@ -656,6 +659,16 @@ func pickup_apply(type,ammo_type,value): level_control.money += value +func focus_on_target(): + if Engine.time_scale < 1: + const BLUR_AMOUNT = .1 + camera.attributes.dof_blur_far_enabled = false + camera.attributes.dof_blur_near_enabled = true + camera.attributes.dof_blur_amount = lerp(0.0,BLUR_AMOUNT,1.0 - Engine.time_scale) + else: + camera.attributes.dof_blur_far_enabled = false + camera.attributes.dof_blur_near_enabled = false + func weapon_tilt(input_x, delta): if !ads: if weapon_holder: