diff --git a/assets/textures/move_target.png b/assets/textures/move_target.png new file mode 100644 index 0000000..efc92d7 --- /dev/null +++ b/assets/textures/move_target.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51c8d2eaa5679d0e2300b99afdaee15535a87100e67bd0fe8ff0e94adf034570 +size 8219 diff --git a/assets/textures/move_target.png.import b/assets/textures/move_target.png.import new file mode 100644 index 0000000..b3e7f12 --- /dev/null +++ b/assets/textures/move_target.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dusadvumlagrq" +path.s3tc="res://.godot/imported/move_target.png-9737dedba86278778bc0199cdb663eb6.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://assets/textures/move_target.png" +dest_files=["res://.godot/imported/move_target.png-9737dedba86278778bc0199cdb663eb6.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +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=0 diff --git a/resources/materials/indicators/move_target_mat.tres b/resources/materials/indicators/move_target_mat.tres new file mode 100644 index 0000000..76029cd --- /dev/null +++ b/resources/materials/indicators/move_target_mat.tres @@ -0,0 +1,12 @@ +[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://dgsd4m4dnqddv"] + +[ext_resource type="Texture2D" uid="uid://dusadvumlagrq" path="res://assets/textures/move_target.png" id="1_a26g5"] + +[resource] +transparency = 2 +alpha_scissor_threshold = 0.5 +alpha_antialiasing_mode = 0 +shading_mode = 0 +albedo_texture = ExtResource("1_a26g5") +disable_receive_shadows = true +billboard_keep_scale = true diff --git a/scenes/units/abstract/controlled_unit.tscn b/scenes/units/abstract/controlled_unit.tscn index 0813f5f..33e3876 100644 --- a/scenes/units/abstract/controlled_unit.tscn +++ b/scenes/units/abstract/controlled_unit.tscn @@ -1,17 +1,28 @@ -[gd_scene load_steps=5 format=3 uid="uid://cidd3q2tet7ku"] +[gd_scene load_steps=7 format=3 uid="uid://cidd3q2tet7ku"] [ext_resource type="PackedScene" uid="uid://c70vx0utm5knp" path="res://scenes/units/abstract/unit.tscn" id="1_iivmb"] [ext_resource type="Script" path="res://scripts/units/abstract/controlled_unit.gd" id="2_ruawn"] [ext_resource type="Material" uid="uid://bghl8uypb17xy" path="res://resources/materials/indicators/select_indicator_mat.tres" id="3_3totu"] +[ext_resource type="Material" uid="uid://dgsd4m4dnqddv" path="res://resources/materials/indicators/move_target_mat.tres" id="3_7b21u"] [sub_resource type="QuadMesh" id="QuadMesh_4fevy"] material = ExtResource("3_3totu") center_offset = Vector3(0, 0.001, 0) orientation = 1 +[sub_resource type="QuadMesh" id="QuadMesh_ewb03"] +material = ExtResource("3_7b21u") +center_offset = Vector3(0, 0.001, 0) +orientation = 1 + [node name="ControlledUnit" instance=ExtResource("1_iivmb")] script = ExtResource("2_ruawn") [node name="SelectionIndicator" type="MeshInstance3D" parent="." index="6"] cast_shadow = 0 mesh = SubResource("QuadMesh_4fevy") + +[node name="MoveTarget" type="MeshInstance3D" parent="." index="7"] +top_level = true +cast_shadow = 0 +mesh = SubResource("QuadMesh_ewb03") diff --git a/scripts/units/abstract/controlled_unit.gd b/scripts/units/abstract/controlled_unit.gd index bb34018..eda49b8 100644 --- a/scripts/units/abstract/controlled_unit.gd +++ b/scripts/units/abstract/controlled_unit.gd @@ -12,6 +12,7 @@ var _is_moving: bool = false var _ground_plane: Plane = Plane(Vector3.UP, 0) @onready var selection_indicator: VisualInstance3D = $SelectionIndicator +@onready var move_target_indicator: VisualInstance3D = $MoveTarget static func get_cost() -> int: @@ -34,6 +35,7 @@ func _process(delta: float) -> void: super._process(delta) selection_indicator.visible = _selected hover_indicator.visible = _hovered or _hovered_rect + move_target_indicator.visible = _is_moving and (_selected or showing_info) func _physics_process(delta: float) -> void: @@ -80,6 +82,8 @@ func set_selected(on: bool) -> void: func navigate(to: Vector3, moving: bool = false) -> void: _is_moving = moving nav_agent.set_target_position(to) + if _is_moving: + move_target_indicator.global_position = nav_agent.target_position func _interact(with: Interactable) -> void: