diff --git a/Asset Sources/HUD/Vignette.svg b/Asset Sources/HUD/Vignette.svg new file mode 100644 index 0000000..0508dfc --- /dev/null +++ b/Asset Sources/HUD/Vignette.svg @@ -0,0 +1,89 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/Game/Assets/Characters/Player.gd b/Game/Assets/Characters/Player.gd index dfbc4a5..1deac28 100644 --- a/Game/Assets/Characters/Player.gd +++ b/Game/Assets/Characters/Player.gd @@ -4,8 +4,22 @@ extends KinematicBody3D #var speed := 15 @onready var head = $Head +@onready var camera = $Head/Camera +@onready var tween = $Head/Camera/Tween @onready var ground_check = $GroundCheck +@onready var hud = get_tree().root.find_node("HUD", true, false) +@onready var crosshair = hud.get_node("Crosshair") +@onready var vignette = hud.get_node("Vignette") + +var base_fov = 90 +var view_zoom := 1.0 : + set(zoom): + view_zoom = zoom + camera.fov = base_fov / (zoom * 4) + crosshair.modulate.a = 1 - (zoom - 1) * 2 + vignette.material["shader_param/Factor"] = zoom + var direction := Vector3.ZERO var accel := 0 var speed := 0 @@ -31,15 +45,16 @@ var snap := Vector3.ZERO func _ready() -> void: Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + view_zoom = .0 func aim(event) -> void: var mouse_motion = event as InputEventMouseMotion if mouse_motion: - rotation_degrees.y -= mouse_motion.relative.x * mouse_sensitivity + rotation_degrees.y -= mouse_motion.relative.x * mouse_sensitivity / view_zoom var current_tilt: float = head.rotation_degrees.x - current_tilt -= mouse_motion.relative.y * mouse_sensitivity + current_tilt -= mouse_motion.relative.y * mouse_sensitivity / view_zoom head.rotation_degrees.x = clamp(current_tilt, -90, 90) func _input(event) -> void: @@ -49,18 +64,32 @@ func _input(event) -> void: Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) else: Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) - + + if Input.is_action_just_pressed("view_zoom"): + #tween.stop_all() + tween.interpolate_property(self, "view_zoom", view_zoom, 1.0, 0.5, Tween.TRANS_SINE, Tween.EASE_IN_OUT) + tween.start() + crosshair.hide() + + if Input.is_action_just_released("view_zoom"): + #tween.stop_all() + tween.interpolate_property(self, "view_zoom", view_zoom, 0.0, 0.25, Tween.TRANS_SINE, Tween.EASE_IN_OUT) + tween.start() + crosshair.show() + aim(event) func _physics_process(delta): direction = Vector3.ZERO + snap = Vector3.ZERO + if is_on_floor() and ground_check.is_colliding(): - snap = -get_floor_normal() + #snap = -get_floor_normal() medium = "ground" gravity_vec = Vector3.ZERO else: - snap = Vector3.DOWN + #snap = Vector3.DOWN medium = "air" gravity_vec += Vector3.DOWN * gravity * delta @@ -89,7 +118,7 @@ func _physics_process(delta): slide = move_and_slide_with_snap(movement, snap, Vector3.UP) - if not is_on_floor(): # while in mid-air collisions affect momentum + if not is_on_floor() and not ground_check.is_colliding(): # while in mid-air collisions affect momentum velocity.x = slide.x velocity.z = slide.z gravity_vec.y = slide.y diff --git a/Game/Assets/Characters/Player.tscn b/Game/Assets/Characters/Player.tscn index 458ee36..b1ad2c7 100644 --- a/Game/Assets/Characters/Player.tscn +++ b/Game/Assets/Characters/Player.tscn @@ -33,6 +33,9 @@ current = true fov = 90.0 script = null +[node name="Tween" type="Tween" parent="Head/Camera"] +script = null + [node name="Hand" type="Node3D" parent="Head/Camera"] script = null diff --git a/Game/Assets/HUD/Crosshair.gd b/Game/Assets/HUD/Crosshair.gd index 92899db..eae53ff 100644 --- a/Game/Assets/HUD/Crosshair.gd +++ b/Game/Assets/HUD/Crosshair.gd @@ -9,3 +9,11 @@ func hit(): func kill(): aplayer.stop() aplayer.play("Kill") + +#func hide(): +# aplayer.stop() +# aplayer.play("Hide") +## +#func show(): +# aplayer.stop() +# aplayer.play("Show") diff --git a/Game/Assets/HUD/Vignette.png b/Game/Assets/HUD/Vignette.png new file mode 100644 index 0000000..17c99a6 Binary files /dev/null and b/Game/Assets/HUD/Vignette.png differ diff --git a/Game/Assets/HUD/Vignette.png.import b/Game/Assets/HUD/Vignette.png.import new file mode 100644 index 0000000..6152e18 --- /dev/null +++ b/Game/Assets/HUD/Vignette.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture2D" +path="res://.godot/imported/Vignette.png-91c9a8d7fb2c16e38f32b60a556ba3a5.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/HUD/Vignette.png" +dest_files=[ "res://.godot/imported/Vignette.png-91c9a8d7fb2c16e38f32b60a556ba3a5.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/bptc_ldr=0 +compress/normal_map=0 +compress/channel_pack=0 +compress/streamed=false +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/invert_color=false +process/HDR_as_SRGB=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 diff --git a/Game/Main.tscn b/Game/Main.tscn index 672a365..72aad29 100644 --- a/Game/Main.tscn +++ b/Game/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=2] +[gd_scene load_steps=24 format=2] [ext_resource path="res://Assets/Characters/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://Assets/HUD/Crosshair.png" type="Texture2D" id=2] @@ -6,6 +6,8 @@ [ext_resource path="res://Assets/HUD/Crosshair.gd" type="Script" id=4] [ext_resource path="res://Assets/SFX/UI_Confirm_Hit.wav" type="AudioStream" id=5] [ext_resource path="res://Assets/SFX/UI_Confirm_Kill.wav" type="AudioStream" id=6] +[ext_resource path="res://Assets/Props/BeerCan.tscn" type="PackedScene" id=7] +[ext_resource path="res://Assets/HUD/Vignette.png" type="Texture2D" id=8] [sub_resource type="PhysicalSkyMaterial" id=1] @@ -59,7 +61,23 @@ tracks/0/keys = { } [sub_resource type="Animation" id=7] -resource_name = "Hit" +resource_name = "Hide" +length = 0.2 +step = 0.05 +tracks/0/type = "value" +tracks/0/path = NodePath("Crosshair:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PackedFloat32Array( 0, 0.2 ), +"transitions": PackedFloat32Array( 1, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ] +} + +[sub_resource type="Animation" id=8] length = 0.2 step = 0.05 tracks/0/type = "value" @@ -89,8 +107,7 @@ tracks/1/keys = { "times": PackedFloat32Array( 0 ) } -[sub_resource type="Animation" id=8] -resource_name = "Kill" +[sub_resource type="Animation" id=9] length = 0.5 step = 0.05 tracks/0/type = "value" @@ -120,6 +137,90 @@ tracks/1/keys = { "times": PackedFloat32Array( 0 ) } +[sub_resource type="Animation" id=10] +resource_name = "Show" +length = 0.2 +step = 0.05 +tracks/0/type = "value" +tracks/0/path = NodePath("Crosshair:modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PackedFloat32Array( 0, 0.2 ), +"transitions": PackedFloat32Array( 1, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ] +} + +[sub_resource type="VisualShaderNodeFloatUniform" id=11] +default_input_values = [ ] +uniform_name = "Factor" +hint = 1 +default_value_enabled = true + +[sub_resource type="VisualShaderNodeInput" id=12] +output_port_for_preview = 0 +default_input_values = [ ] +input_name = "color" + +[sub_resource type="VisualShaderNodeMix" id=13] +default_input_values = [ 0, Vector3( 1, 1, 1 ), 1, Vector3( 1, 1, 1 ), 2, 0.5 ] +op_type = 2 + +[sub_resource type="VisualShader" id=14] +code = "shader_type canvas_item; +render_mode blend_mul; + +uniform float Factor : hint_range(0, 1) = 0; + + + +void vertex() { +// Output:0 + +} + +void fragment() { +// Input:3 + vec3 n_out3p0 = COLOR.rgb; + +// FloatUniform:2 + float n_out2p0 = Factor; + +// Mix:4 + vec3 n_in4p0 = vec3(1.00000, 1.00000, 1.00000); + vec3 n_out4p0 = mix(n_in4p0, n_out3p0, n_out2p0); + +// Output:0 + COLOR.rgb = n_out4p0; + +} + +void light() { +// Output:0 + +} +" +graph_offset = Vector2( -113, 35 ) +version = "4.0" +mode = 1 +modes/blend = 3 +flags/light_only = false +nodes/fragment/0/position = Vector2( 400, 180 ) +nodes/fragment/2/node = SubResource( 11 ) +nodes/fragment/2/position = Vector2( -440, 300 ) +nodes/fragment/3/node = SubResource( 12 ) +nodes/fragment/3/position = Vector2( -400, 120 ) +nodes/fragment/4/node = SubResource( 13 ) +nodes/fragment/4/position = Vector2( 60, 180 ) +nodes/fragment/connections = PackedInt32Array( 4, 0, 0, 0, 2, 0, 4, 2, 3, 0, 4, 1 ) + +[sub_resource type="ShaderMaterial" id=15] +shader = SubResource( 14 ) +shader_param/Factor = 0.0 + [node name="Game" type="Node3D"] script = null @@ -170,7 +271,6 @@ __meta__ = { } [node name="Crosshair" type="TextureRect" parent="HUD/Crosshair"] -modulate = Color( 1, 0.716667, 0, 1 ) texture_filter = 2 anchor_left = 0.5 anchor_top = 0.5 @@ -191,8 +291,10 @@ __meta__ = { [node name="AnimationPlayer" type="AnimationPlayer" parent="HUD/Crosshair"] autoplay = "Default" anims/Default = SubResource( 6 ) -anims/Hit = SubResource( 7 ) -anims/Kill = SubResource( 8 ) +anims/Hide = SubResource( 7 ) +anims/Hit = SubResource( 8 ) +anims/Kill = SubResource( 9 ) +anims/Show = SubResource( 10 ) blend_times = [ ] script = null @@ -200,6 +302,18 @@ script = null stream = ExtResource( 6 ) script = null +[node name="Vignette" type="TextureRect" parent="HUD"] +material = SubResource( 15 ) +anchor_right = 1.0 +anchor_bottom = 1.0 +texture = ExtResource( 8 ) +expand = true +stretch_mode = 7 +script = null +__meta__ = { +"_edit_use_anchors_": false +} + [node name="Player" parent="." instance=ExtResource( 1 )] [node name="ReflectionProbe" type="ReflectionProbe" parent="."] @@ -209,4 +323,7 @@ box_projection = true enable_shadows = true script = null +[node name="BeerCan" parent="." instance=ExtResource( 7 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 22, 11, -3 ) + [editable path="DM1"]