diff --git a/assets/crosshair.png b/assets/crosshair.png new file mode 100644 index 0000000..8e6387f Binary files /dev/null and b/assets/crosshair.png differ diff --git a/assets/crosshair.png.import b/assets/crosshair.png.import new file mode 100644 index 0000000..39777bf --- /dev/null +++ b/assets/crosshair.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dkc0fn50ueqc5" +path="res://.godot/imported/crosshair.png-7a5ee98d03b748045923e3a0fa977b20.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/crosshair.png" +dest_files=["res://.godot/imported/crosshair.png-7a5ee98d03b748045923e3a0fa977b20.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/Main.tscn b/scenes/Main.tscn index a1e7152..24be565 100644 --- a/scenes/Main.tscn +++ b/scenes/Main.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=5 format=3 uid="uid://bn6y24u16jtdj"] +[gd_scene load_steps=7 format=3 uid="uid://bn6y24u16jtdj"] [ext_resource type="PackedScene" uid="uid://b7o2y54duqxft" path="res://scenes/World.tscn" id="1_px6sj"] [ext_resource type="Shader" path="res://shaders/outline.gdshader" id="2_dd8cf"] [ext_resource type="Script" path="res://scripts/CloneMainCamera.gd" id="2_m7qgc"] +[ext_resource type="Texture2D" uid="uid://dkc0fn50ueqc5" path="res://assets/crosshair.png" id="4_6ai7y"] +[ext_resource type="Script" path="res://scripts/Crosshair.gd" id="5_mrx5k"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_7rvwk"] shader = ExtResource("2_dd8cf") @@ -31,3 +33,28 @@ render_target_update_mode = 4 [node name="ClonedCamera" type="Camera3D" parent="SubViewportContainer/OutlineViewport"] cull_mask = 2 script = ExtResource("2_m7qgc") + +[node name="HUD" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 + +[node name="Crosshair" type="TextureRect" parent="HUD"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -10.5 +offset_top = -10.5 +offset_right = 10.5 +offset_bottom = 10.5 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("4_6ai7y") +script = ExtResource("5_mrx5k") diff --git a/scripts/Crosshair.gd b/scripts/Crosshair.gd new file mode 100644 index 0000000..87e48ff --- /dev/null +++ b/scripts/Crosshair.gd @@ -0,0 +1,4 @@ +extends TextureRect + +func _process(_delta: float) -> void: + visible = Input.mouse_mode == Input.MOUSE_MODE_CAPTURED diff --git a/scripts/PickupController.gd b/scripts/PickupController.gd index 3016543..7ff6371 100644 --- a/scripts/PickupController.gd +++ b/scripts/PickupController.gd @@ -17,6 +17,8 @@ func _ready() -> void: func _input(event: InputEvent) -> void: + if Input.mouse_mode != Input.MOUSE_MODE_CAPTURED: return + ensure_current_item_valid() if !current_item: return