add bone size variation to aphids

This commit is contained in:
Teatov 2024-10-21 18:48:22 +10:00
parent 0c5db39e9e
commit 9e232a8fcc
3 changed files with 22 additions and 3 deletions

View File

@ -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")

View File

@ -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")

View File

@ -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: