replace Sprite3Ds with MeshInstances

This commit is contained in:
2024-10-07 21:28:10 +10:00
parent f24fa3c99f
commit 25f2867ac6
14 changed files with 147 additions and 81 deletions

View File

@@ -0,0 +1,10 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://c33we3533cr8k"]
[ext_resource type="Texture2D" uid="uid://pbcyrj6uvp40" path="res://assets/textures/items/honeydew.png" id="1_rqagm"]
[resource]
transparency = 2
alpha_scissor_threshold = 0.5
alpha_antialiasing_mode = 0
albedo_texture = ExtResource("1_rqagm")
billboard_mode = 1

View File

@@ -0,0 +1,11 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://jkh5iskawwry"]
[ext_resource type="Texture2D" uid="uid://bjayd45yvgpj8" path="res://assets/textures/gathering_radius.png" id="1_d1h4a"]
[resource]
transparency = 2
alpha_scissor_threshold = 0.5
alpha_antialiasing_mode = 0
shading_mode = 0
albedo_texture = ExtResource("1_d1h4a")
disable_receive_shadows = true

View File

@@ -0,0 +1,11 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://f0nlf4tdpvbd"]
[ext_resource type="Texture2D" uid="uid://duf132faskeid" path="res://assets/textures/selection_unit_hover_decal.png" id="1_e7qu0"]
[resource]
transparency = 2
alpha_scissor_threshold = 0.5
alpha_antialiasing_mode = 0
shading_mode = 0
albedo_texture = ExtResource("1_e7qu0")
disable_receive_shadows = true

View File

@@ -0,0 +1,11 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://bghl8uypb17xy"]
[ext_resource type="Texture2D" uid="uid://dehqm00kiljut" path="res://assets/textures/selection_unit_decal.png" id="1_fkga0"]
[resource]
transparency = 2
alpha_scissor_threshold = 0.5
alpha_antialiasing_mode = 0
shading_mode = 0
albedo_texture = ExtResource("1_fkga0")
disable_receive_shadows = true

View File

@@ -1,29 +1,34 @@
[gd_scene load_steps=5 format=3 uid="uid://dx544tb0so0b4"]
[gd_scene load_steps=7 format=3 uid="uid://dx544tb0so0b4"]
[ext_resource type="Script" path="res://scripts/items/honeydew.gd" id="1_6fg3d"]
[ext_resource type="Texture2D" uid="uid://pbcyrj6uvp40" path="res://assets/textures/items/honeydew.png" id="1_a35ol"]
[ext_resource type="Texture2D" uid="uid://duf132faskeid" path="res://assets/textures/selection_unit_hover_decal.png" id="2_vinjw"]
[ext_resource type="Material" uid="uid://c33we3533cr8k" path="res://resources/materials/honeydew_mat.tres" id="2_fnxpb"]
[ext_resource type="Material" uid="uid://f0nlf4tdpvbd" path="res://resources/materials/indicators/hover_indicator_mat.tres" id="3_cofwb"]
[sub_resource type="QuadMesh" id="QuadMesh_6pru1"]
material = ExtResource("2_fnxpb")
size = Vector2(0.23, 0.23)
[sub_resource type="SphereShape3D" id="SphereShape3D_8lnyq"]
radius = 0.1
[sub_resource type="QuadMesh" id="QuadMesh_qwehm"]
material = ExtResource("3_cofwb")
center_offset = Vector3(0, 0.001, 0)
orientation = 1
[node name="Honeydew" type="CharacterBody3D"]
collision_layer = 256
collision_mask = 0
script = ExtResource("1_6fg3d")
[node name="Sprite3D" type="Sprite3D" parent="."]
pixel_size = 0.0009
billboard = 1
shaded = true
alpha_cut = 1
texture = ExtResource("1_a35ol")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1.08549, 0, 0, 0, 1.08549, 0, 0, 0, 1.08549, 0, 0, 0)
mesh = SubResource("QuadMesh_6pru1")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_8lnyq")
[node name="HoverSprite" type="Sprite3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0021804, -0.0180028, -0.00236732)
pixel_size = 0.004
axis = 1
texture = ExtResource("2_vinjw")
[node name="HoverIndicator" type="MeshInstance3D" parent="."]
transform = Transform3D(0.519898, 0, 0, 0, 0.519898, 0, 0, 0, 0.519898, 0, -0.0175649, 0)
cast_shadow = 0
mesh = SubResource("QuadMesh_qwehm")

View File

@@ -1,12 +1,17 @@
[gd_scene load_steps=5 format=3 uid="uid://clftjlaotf2g2"]
[gd_scene load_steps=6 format=3 uid="uid://clftjlaotf2g2"]
[ext_resource type="Script" path="res://scripts/anthill.gd" id="1_8k02d"]
[ext_resource type="Texture2D" uid="uid://duf132faskeid" path="res://assets/textures/selection_unit_hover_decal.png" id="1_bk5n4"]
[ext_resource type="Material" uid="uid://f0nlf4tdpvbd" path="res://resources/materials/indicators/hover_indicator_mat.tres" id="2_44p2d"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_x8apu"]
[sub_resource type="BoxShape3D" id="BoxShape3D_ruupa"]
[sub_resource type="QuadMesh" id="QuadMesh_2gykr"]
material = ExtResource("2_44p2d")
center_offset = Vector3(0, 0.001, 0)
orientation = 1
[node name="Anthill" type="CharacterBody3D"]
collision_mask = 0
script = ExtResource("1_8k02d")
@@ -18,11 +23,10 @@ mesh = SubResource("CapsuleMesh_x8apu")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
shape = SubResource("BoxShape3D_ruupa")
[node name="HoverSprite" type="Sprite3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0021804, 0.00953716, -0.00236732)
pixel_size = 0.0135
axis = 1
texture = ExtResource("1_bk5n4")
[node name="UiOrigin" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.15587, 0)
[node name="HoverIndicator" type="MeshInstance3D" parent="."]
transform = Transform3D(1.62268, 0, 0, 0, 1.62268, 0, 0, 0, 1.62268, 0, 0, 0)
cast_shadow = 0
mesh = SubResource("QuadMesh_2gykr")

View File

@@ -1,11 +1,10 @@
[gd_scene load_steps=13 format=3 uid="uid://wrj8fnh5y6e8"]
[gd_scene load_steps=14 format=3 uid="uid://wrj8fnh5y6e8"]
[ext_resource type="PackedScene" uid="uid://bi231xk2sp410" path="res://assets/models/ant.glb" id="1_asokb"]
[ext_resource type="Script" path="res://scripts/units/ant_gatherer.gd" id="2_vcqni"]
[ext_resource type="Texture2D" uid="uid://dehqm00kiljut" path="res://assets/textures/selection_unit_decal.png" id="3_5dykx"]
[ext_resource type="Texture2D" uid="uid://duf132faskeid" path="res://assets/textures/selection_unit_hover_decal.png" id="4_1jps0"]
[ext_resource type="Material" uid="uid://bghl8uypb17xy" path="res://resources/materials/indicators/select_indicator_mat.tres" id="3_nb346"]
[ext_resource type="Material" uid="uid://f0nlf4tdpvbd" path="res://resources/materials/indicators/hover_indicator_mat.tres" id="4_rnrdj"]
[ext_resource type="PackedScene" uid="uid://fal1ond30jey" path="res://scenes/units/components/gathering.tscn" id="5_wwnxg"]
[ext_resource type="Script" path="res://scripts/units/components/gathering.gd" id="6_dq55a"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_foq4x"]
animation = &"idle"
@@ -31,6 +30,16 @@ transitions = ["Start", "locomotion", SubResource("AnimationNodeStateMachineTran
[sub_resource type="SphereShape3D" id="SphereShape3D_e8dcp"]
radius = 0.25
[sub_resource type="QuadMesh" id="QuadMesh_oducb"]
material = ExtResource("3_nb346")
center_offset = Vector3(0, 0.001, 0)
orientation = 1
[sub_resource type="QuadMesh" id="QuadMesh_tiyt4"]
material = ExtResource("4_rnrdj")
center_offset = Vector3(0, 0.001, 0)
orientation = 1
[node name="AntGatherer" instance=ExtResource("1_asokb")]
collision_layer = 4
collision_mask = 0
@@ -56,7 +65,6 @@ bones/23/rotation = Quaternion(0.0294712, -5.33139e-15, 4.35675e-07, 0.999566)
bones/24/rotation = Quaternion(0.0294712, -6.21995e-15, 4.35675e-07, 0.999566)
bones/25/rotation = Quaternion(0.0294712, -5.33139e-15, 4.35675e-07, 0.999566)
bones/26/rotation = Quaternion(-0.221628, 0.221633, -0.671475, 0.671477)
bones/26/scale = Vector3(1, 1, 1)
bones/27/rotation = Quaternion(0.583948, -8.29882e-08, 2.36539e-06, 0.811791)
bones/27/scale = Vector3(1, 1, 1)
bones/28/rotation = Quaternion(-0.84146, 6.60837e-08, -6.26108e-06, 0.54032)
@@ -66,7 +74,6 @@ bones/32/scale = Vector3(1, 1, 1)
bones/34/rotation = Quaternion(-0.841459, 1.31575e-07, -6.3826e-06, 0.540321)
bones/34/scale = Vector3(1, 1, 1)
bones/35/rotation = Quaternion(-0.221628, -0.221633, 0.671475, 0.671477)
bones/35/scale = Vector3(1, 1, 1)
bones/36/rotation = Quaternion(0.583948, 8.29882e-08, -2.36539e-06, 0.811791)
bones/36/scale = Vector3(1, 1, 1)
bones/37/rotation = Quaternion(-0.84146, -6.60837e-08, 6.26108e-06, 0.54032)
@@ -91,17 +98,15 @@ parameters/locomotion/blend_position = 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0)
shape = SubResource("SphereShape3D_e8dcp")
[node name="SelectionSprite" type="Sprite3D" parent="." index="4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0021804, 0.00953716, -0.00236732)
pixel_size = 0.0055
axis = 1
texture = ExtResource("3_5dykx")
[node name="SelectionIndicator" type="MeshInstance3D" parent="." index="4"]
transform = Transform3D(0.699626, 0, 0, 0, 0.699626, 0, 0, 0, 0.699626, 0, 0, 0)
cast_shadow = 0
mesh = SubResource("QuadMesh_oducb")
[node name="HoverSprite" type="Sprite3D" parent="." index="5"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0021804, 0.00953716, -0.00236732)
pixel_size = 0.0085
axis = 1
texture = ExtResource("4_1jps0")
[node name="HoverIndicator" type="MeshInstance3D" parent="." index="5"]
transform = Transform3D(1.08549, 0, 0, 0, 1.08549, 0, 0, 0, 1.08549, 0, 0, 0)
cast_shadow = 0
mesh = SubResource("QuadMesh_tiyt4")
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="." index="6"]
path_desired_distance = 0.5
@@ -115,11 +120,7 @@ neighbor_distance = 10.0
[node name="VisibleOnScreenNotifier3D" type="VisibleOnScreenNotifier3D" parent="." index="7"]
aabb = AABB(-0.5, 0, -0.5, 1, 0.5, 1)
[node name="Gathering" type="Area3D" parent="." index="8" instance=ExtResource("5_wwnxg")]
collision_layer = 256
collision_mask = 256
input_ray_pickable = false
script = ExtResource("6_dq55a")
[node name="Gathering" parent="." index="8" instance=ExtResource("5_wwnxg")]
[node name="UiOrigin" type="Marker3D" parent="." index="9"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.58746, 0)

View File

@@ -1,9 +1,9 @@
[gd_scene load_steps=12 format=3 uid="uid://k11usj2shbtr"]
[gd_scene load_steps=14 format=3 uid="uid://k11usj2shbtr"]
[ext_resource type="PackedScene" uid="uid://bi231xk2sp410" path="res://assets/models/ant.glb" id="1_1u65s"]
[ext_resource type="Script" path="res://scripts/units/ant_nitwit.gd" id="2_f1bdv"]
[ext_resource type="Texture2D" uid="uid://dehqm00kiljut" path="res://assets/textures/selection_unit_decal.png" id="3_hxm2m"]
[ext_resource type="Texture2D" uid="uid://duf132faskeid" path="res://assets/textures/selection_unit_hover_decal.png" id="4_vrkmw"]
[ext_resource type="Material" uid="uid://bghl8uypb17xy" path="res://resources/materials/indicators/select_indicator_mat.tres" id="3_pq5m5"]
[ext_resource type="Material" uid="uid://f0nlf4tdpvbd" path="res://resources/materials/indicators/hover_indicator_mat.tres" id="4_tsqc2"]
[ext_resource type="PackedScene" uid="uid://fal1ond30jey" path="res://scenes/units/components/gathering.tscn" id="5_j8w6w"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_foq4x"]
@@ -30,6 +30,16 @@ transitions = ["Start", "locomotion", SubResource("AnimationNodeStateMachineTran
[sub_resource type="SphereShape3D" id="SphereShape3D_e8dcp"]
radius = 0.25
[sub_resource type="QuadMesh" id="QuadMesh_r0l7j"]
material = ExtResource("3_pq5m5")
center_offset = Vector3(0, 0.001, 0)
orientation = 1
[sub_resource type="QuadMesh" id="QuadMesh_1jssl"]
material = ExtResource("4_tsqc2")
center_offset = Vector3(0, 0.001, 0)
orientation = 1
[node name="AntNitwit" instance=ExtResource("1_1u65s")]
collision_layer = 4
collision_mask = 0
@@ -88,17 +98,15 @@ parameters/locomotion/blend_position = 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0)
shape = SubResource("SphereShape3D_e8dcp")
[node name="SelectionSprite" type="Sprite3D" parent="." index="4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0021804, 0.00953716, -0.00236732)
pixel_size = 0.0055
axis = 1
texture = ExtResource("3_hxm2m")
[node name="SelectionIndicator" type="MeshInstance3D" parent="." index="4"]
transform = Transform3D(0.699626, 0, 0, 0, 0.699626, 0, 0, 0, 0.699626, 0, 0, 0)
cast_shadow = 0
mesh = SubResource("QuadMesh_r0l7j")
[node name="HoverSprite" type="Sprite3D" parent="." index="5"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0021804, 0.00953716, -0.00236732)
pixel_size = 0.0085
axis = 1
texture = ExtResource("4_vrkmw")
[node name="HoverIndicator" type="MeshInstance3D" parent="." index="5"]
transform = Transform3D(1.08549, 0, 0, 0, 1.08549, 0, 0, 0, 1.08549, 0, 0, 0)
cast_shadow = 0
mesh = SubResource("QuadMesh_1jssl")
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="." index="6"]
path_desired_distance = 0.5

View File

@@ -1,9 +1,9 @@
[gd_scene load_steps=11 format=3 uid="uid://cwi5twmeq7b2a"]
[gd_scene load_steps=12 format=3 uid="uid://cwi5twmeq7b2a"]
[ext_resource type="PackedScene" uid="uid://ch02ae8fj2lhh" path="res://assets/models/aphid.glb" id="1_cchbm"]
[ext_resource type="Script" path="res://scripts/units/aphid.gd" id="2_ohs5l"]
[ext_resource type="Material" uid="uid://f5ibq3dhugoo" path="res://resources/materials/aphid_mat.tres" id="3_dcaja"]
[ext_resource type="Texture2D" uid="uid://duf132faskeid" path="res://assets/textures/selection_unit_hover_decal.png" id="3_wmvub"]
[ext_resource type="Material" uid="uid://f0nlf4tdpvbd" path="res://resources/materials/indicators/hover_indicator_mat.tres" id="4_76tmp"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_akr28"]
animation = &"idle"
@@ -30,6 +30,11 @@ transitions = ["Start", "locomotion", SubResource("AnimationNodeStateMachineTran
[sub_resource type="SphereShape3D" id="SphereShape3D_0fs3n"]
radius = 0.25
[sub_resource type="QuadMesh" id="QuadMesh_jnwlp"]
material = ExtResource("4_76tmp")
center_offset = Vector3(0, 0.001, 0)
orientation = 1
[node name="Aphid" instance=ExtResource("1_cchbm")]
collision_layer = 2
collision_mask = 0
@@ -47,11 +52,10 @@ parameters/locomotion/blend_position = 0.00585774
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0)
shape = SubResource("SphereShape3D_0fs3n")
[node name="HoverSprite" type="Sprite3D" parent="." index="4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0021804, 0.00953716, -0.00236732)
pixel_size = 0.006
axis = 1
texture = ExtResource("3_wmvub")
[node name="HoverIndicator" type="MeshInstance3D" parent="." index="4"]
transform = Transform3D(0.813994, 0, 0, 0, 0.813994, 0, 0, 0, 0.813994, 0, 0, 0)
cast_shadow = 0
mesh = SubResource("QuadMesh_jnwlp")
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="." index="5"]
path_desired_distance = 0.5

View File

@@ -1,11 +1,16 @@
[gd_scene load_steps=4 format=3 uid="uid://fal1ond30jey"]
[gd_scene load_steps=5 format=3 uid="uid://fal1ond30jey"]
[ext_resource type="Script" path="res://scripts/units/components/gathering.gd" id="1_ciwtf"]
[ext_resource type="Texture2D" uid="uid://bjayd45yvgpj8" path="res://assets/textures/gathering_radius.png" id="2_7fj15"]
[ext_resource type="Material" uid="uid://jkh5iskawwry" path="res://resources/materials/indicators/gathering_radius_mat.tres" id="2_r26em"]
[sub_resource type="SphereShape3D" id="SphereShape3D_eqrj3"]
radius = 1.0
[sub_resource type="QuadMesh" id="QuadMesh_ks8es"]
material = ExtResource("2_r26em")
center_offset = Vector3(0, 0.001, 0)
orientation = 1
[node name="Gathering" type="Area3D"]
collision_layer = 256
collision_mask = 256
@@ -15,10 +20,6 @@ script = ExtResource("1_ciwtf")
[node name="NearbyItemsSearch" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_eqrj3")
[node name="Sprite3D" type="Sprite3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.001, 0)
sorting_offset = 5.0
pixel_size = 0.004
axis = 1
alpha_cut = 1
texture = ExtResource("2_7fj15")
[node name="GatheringRadius" type="MeshInstance3D" parent="."]
cast_shadow = 0
mesh = SubResource("QuadMesh_ks8es")

View File

@@ -7,11 +7,11 @@ var hovered: bool = false
var can_interact: bool = true
var click_position: Vector2 = Vector2.ZERO
@onready var hover_sprite: Sprite3D = $HoverSprite
@onready var hover_indicator: VisualInstance3D = $HoverIndicator
func _ready() -> void:
assert(hover_sprite != null, "hover_sprite missing!")
assert(hover_indicator != null, "hover_indicator missing!")
func _process(_delta: float) -> void:
@@ -19,7 +19,7 @@ func _process(_delta: float) -> void:
if not can_interact:
hovered = false
return
hover_sprite.visible = hovered
hover_indicator.visible = hovered
func _input(event: InputEvent) -> void:

View File

@@ -36,7 +36,7 @@ func _process(delta: float) -> void:
(1 - moving_timer),
)
if carried:
hover_sprite.visible = false
hover_indicator.visible = false
func set_carried(on: bool) -> void:

View File

@@ -12,7 +12,7 @@ var moving_to_target: bool = false
var ground_plane: Plane = Plane(Vector3.UP, 0)
@onready var camera: Camera3D = get_viewport().get_camera_3d()
@onready var selection_sprite: Sprite3D = $SelectionSprite
@onready var selection_indicator: VisualInstance3D = $SelectionIndicator
static func get_cost() -> int:
@@ -27,15 +27,15 @@ func _init() -> void:
func _ready() -> void:
assert(camera != null, "camera missing!")
assert(selection_sprite != null, "selection_sprite missing!")
assert(selection_indicator != null, "selection_indicator missing!")
nav_agent.navigation_finished.connect(_on_nav_agent_navigation_finished)
super._ready()
func _process(delta: float) -> void:
super._process(delta)
selection_sprite.visible = selected
hover_sprite.visible = hovered or hovered_rect
selection_indicator.visible = selected
hover_indicator.visible = hovered or hovered_rect
func _physics_process(delta: float) -> void:

View File

@@ -94,7 +94,7 @@ func _animate(delta: float) -> void:
velocity.length() / MOVE_SPEED,
delta * 8
)
animation_tree.set("parameters/locomotion/blend_position", locomotion_value)
# animation_tree.set("parameters/locomotion/blend_position", locomotion_value)
func _wander(delta: float) -> void: