From 9e232a8fcc14e46d883a080e73b6c179f50c807b Mon Sep 17 00:00:00 2001 From: teatov Date: Mon, 21 Oct 2024 18:48:22 +1000 Subject: [PATCH] add bone size variation to aphids --- .../units/abstract/controlled_ant_unit.tscn | 2 +- scenes/units/aphid.tscn | 2 -- scripts/units/aphid.gd | 21 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/scenes/units/abstract/controlled_ant_unit.tscn b/scenes/units/abstract/controlled_ant_unit.tscn index 097645d..123428f 100644 --- a/scenes/units/abstract/controlled_ant_unit.tscn +++ b/scenes/units/abstract/controlled_ant_unit.tscn @@ -65,7 +65,7 @@ visible = false root_node = NodePath("../AntModel") tree_root = SubResource("AnimationNodeStateMachine_v8drs") anim_player = NodePath("../AntModel/AnimationPlayer") -parameters/locomotion/blend_position = 0 +parameters/locomotion/blend_position = 0.023431 [node name="CollisionShape3D" parent="." index="2"] shape = SubResource("CylinderShape3D_8admi") diff --git a/scenes/units/aphid.tscn b/scenes/units/aphid.tscn index 73ae7eb..273d4a1 100644 --- a/scenes/units/aphid.tscn +++ b/scenes/units/aphid.tscn @@ -41,10 +41,8 @@ bones/6/rotation = Quaternion(-3.38449e-07, 0.863712, 0.503987, -5.80021e-07) bones/7/rotation = Quaternion(0.526107, -8.35521e-14, 7.06609e-07, 0.850418) bones/10/rotation = Quaternion(-0.235443, 0.235445, -0.666758, 0.666758) bones/11/rotation = Quaternion(-0.235443, 0.235445, -0.666758, 0.666758) -bones/12/scale = Vector3(1, 1, 1) bones/13/rotation = Quaternion(-0.235443, -0.235445, 0.666758, 0.666758) bones/14/rotation = Quaternion(-0.235443, -0.235445, 0.666758, 0.666758) -bones/15/scale = Vector3(1, 1, 1) [node name="AnimationTree" parent="." index="1"] root_node = NodePath("../AphidModel") diff --git a/scripts/units/aphid.gd b/scripts/units/aphid.gd index 9cf46dc..da0bfa4 100644 --- a/scripts/units/aphid.gd +++ b/scripts/units/aphid.gd @@ -5,6 +5,8 @@ enum State { WANDERING, } +const BONE_SCALE_VARIATION: float = 0.25 + const HONEYDEW_INTERVAL_MIN: float = 5 const HONEYDEW_INTERVAL_MAX: float = 60 const HONEYDEW_SPAWN_SPREAD: float = 0.5 @@ -16,10 +18,29 @@ var spawned_honeydews: Dictionary = {} var honeydew_scene := preload("res://scenes/items/honeydew.tscn") +var _bones_to_scale: PackedStringArray = [ + "Root", + "Antenna_root_L", + "Eye_L", + "Antenna_root_R", + "Eye_R", +] + +@onready var skeleton: Skeleton3D = $AphidModel/Armature/Skeleton3D + func _ready() -> void: + assert(skeleton != null, "skeleton missing!") super._ready() _set_spawn_timer() + for bone_name in _bones_to_scale: + var bone := skeleton.find_bone(bone_name) + var bone_transform := skeleton.get_bone_pose(bone) + bone_transform.basis *= 1 + randf_range( + -BONE_SCALE_VARIATION, + BONE_SCALE_VARIATION, + ) + skeleton.set_bone_pose_scale(bone, Vector3.ZERO) func _process(delta: float) -> void: