Now sheathing works without reparenting nodes.

This commit is contained in:
Relintai 2020-06-16 18:50:49 +02:00
parent 6626b8ed38
commit ad72ae4def
2 changed files with 16 additions and 13 deletions

View File

@ -170,7 +170,7 @@ transform = Transform( -0.0646502, 0.683772, 0.726832, -0.148514, -0.726783, 0.6
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="ShieldAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="2"] [node name="ShieldAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="2"]
transform = Transform( 0.0460429, 0.0993847, 0.993971, -0.0443354, -0.99381, 0.101413, 0.997951, -0.0487388, -0.0413565, 0.204427, 1.01063, 0.00152545 ) transform = Transform( 0.0460429, 0.0993848, 0.993971, -0.0443354, -0.99381, 0.101413, 0.997951, -0.0487388, -0.0413565, 0.204427, 1.01063, 0.00152545 )
bone_name = "left_forearm" bone_name = "left_forearm"
[node name="LeftHandShield" type="Spatial" parent="armature/Armature/Skeleton/ShieldAttachment"] [node name="LeftHandShield" type="Spatial" parent="armature/Armature/Skeleton/ShieldAttachment"]
@ -193,7 +193,7 @@ transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="NeckAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="5"] [node name="NeckAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="5"]
transform = Transform( 0.99998, -0.00629028, -0.000312272, 0.00629784, 0.997246, 0.0731527, -0.000148758, -0.0731576, 0.99732, 0.00103962, 1.31823, 5.39592e-05 ) transform = Transform( 0.99998, -0.00629028, -0.000312272, 0.00629784, 0.997246, 0.0731527, -0.000148758, -0.0731576, 0.99732, 0.00103962, 1.31823, 5.39597e-05 )
bone_name = "neck" bone_name = "neck"
[node name="TorsoAP" type="Spatial" parent="armature/Armature/Skeleton/NeckAttachment"] [node name="TorsoAP" type="Spatial" parent="armature/Armature/Skeleton/NeckAttachment"]
@ -215,14 +215,14 @@ bone_name = "pelvis"
transform = Transform( 0.99343, -0.00240871, -0.114417, 0.00240855, 0.999997, -0.000139626, 0.114417, -0.00013687, 0.993433, 0.144429, 0.18077, 0.165634 ) transform = Transform( 0.99343, -0.00240871, -0.114417, 0.00240855, 0.999997, -0.000139626, 0.114417, -0.00013687, 0.993433, 0.144429, 0.18077, 0.165634 )
[node name="RightBackAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="8"] [node name="RightBackAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="8"]
transform = Transform( 0.999978, -0.00656778, 0.000273144, 0.00656962, 0.999923, -0.00103998, -0.000266317, 0.0010415, 0.999999, 0.00227172, 1.13064, -0.000141409 ) transform = Transform( 0.999978, -0.00656778, 0.000273144, 0.00656962, 0.999923, -0.00103998, -0.000266317, 0.00104151, 0.999999, 0.00227172, 1.13064, -0.000141409 )
bone_name = "spine_2" bone_name = "spine_2"
[node name="RightBackAP" type="Spatial" parent="armature/Armature/Skeleton/RightBackAttachment"] [node name="RightBackAP" type="Spatial" parent="armature/Armature/Skeleton/RightBackAttachment"]
transform = Transform( 0.999997, -0.00244424, -0.000479204, 0.00243884, 0.999966, -3.47705e-05, 0.000479292, 3.44458e-05, 1, 0.000560207, -0.00363708, -0.120332 ) transform = Transform( 0.999997, -0.00244424, -0.000479204, 0.00243884, 0.999966, -3.47705e-05, 0.000479292, 3.44458e-05, 1, 0.000560207, -0.00363708, -0.120332 )
[node name="LeftBackAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="9"] [node name="LeftBackAttachment" type="BoneAttachment" parent="armature/Armature/Skeleton" index="9"]
transform = Transform( 0.999978, -0.00656778, 0.000273144, 0.00656962, 0.999923, -0.00103998, -0.000266317, 0.0010415, 0.999999, 0.00227172, 1.13064, -0.000141409 ) transform = Transform( 0.999978, -0.00656778, 0.000273144, 0.00656962, 0.999923, -0.00103998, -0.000266317, 0.00104151, 0.999999, 0.00227172, 1.13064, -0.000141409 )
bone_name = "spine_2" bone_name = "spine_2"
[node name="LeftBackAP" type="Spatial" parent="armature/Armature/Skeleton/LeftBackAttachment"] [node name="LeftBackAP" type="Spatial" parent="armature/Armature/Skeleton/LeftBackAttachment"]

View File

@ -27,12 +27,9 @@ class_name CharacterSkeketonAttachPoint
var effects : Dictionary var effects : Dictionary
var timed_effects : Dictionary var timed_effects : Dictionary
var follow : int = -1
export(Array, NodePath) var positions : Array export(Array, NodePath) var positions : Array
var position_nodes : Array var follow_node : Spatial = null
func load_positions():
for p in positions:
position_nodes.append(get_node(p))
func add(effect : PackedScene) -> void: func add(effect : PackedScene) -> void:
if effects.has(effect): if effects.has(effect):
@ -71,6 +68,9 @@ func remove(effect : PackedScene) -> void:
func _process(delta : float) -> void: func _process(delta : float) -> void:
if follow_node != null:
global_transform = follow_node.global_transform
for k in timed_effects.keys(): for k in timed_effects.keys():
var data : Array = timed_effects[k] var data : Array = timed_effects[k]
@ -82,8 +82,11 @@ func _process(delta : float) -> void:
timed_effects.erase(k) timed_effects.erase(k)
func set_node_position(index : int) -> void: func set_node_position(index : int) -> void:
if positions.size() != position_nodes.size(): follow = index
load_positions()
get_parent().remove_child(self) if index >= positions.size():
position_nodes[index].add_child(self) index = -1
if follow != -1:
follow_node = get_node(positions[follow]) as Spatial