Improved animations and canceling of interactions.

WorldChunkRefactoring
Martin Felis 2023-06-27 22:26:22 +02:00
parent 2e7f30e214
commit adaf5292fb
7 changed files with 81 additions and 12 deletions

Binary file not shown.

View File

@ -19,10 +19,11 @@ switch_mode = 2
xfade_time = 0.2 xfade_time = 0.2
[sub_resource type="AnimationNodeStateMachineTransition" id=6] [sub_resource type="AnimationNodeStateMachineTransition" id=6]
xfade_time = 0.1
[sub_resource type="AnimationNodeStateMachineTransition" id=7] [sub_resource type="AnimationNodeStateMachineTransition" id=7]
switch_mode = 2 switch_mode = 2
xfade_time = 0.2 xfade_time = 0.3
[sub_resource type="AnimationNodeStateMachine" id=8] [sub_resource type="AnimationNodeStateMachine" id=8]
states/Hit/node = SubResource( 1 ) states/Hit/node = SubResource( 1 )
@ -43,7 +44,7 @@ transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
bones/4/bound_children = [ NodePath("ToolAttachement") ] bones/4/bound_children = [ NodePath("ToolAttachement") ]
[node name="ToolAttachement" type="BoneAttachment" parent="Armature/Skeleton" index="5"] [node name="ToolAttachement" type="BoneAttachment" parent="Armature/Skeleton" index="5"]
transform = Transform( 1, 8.68458e-08, -1.04308e-07, 1.74623e-07, -1, -1.30385e-07, 1.41561e-07, 1.50874e-07, -1, -0.72, 0.45, 3.28113e-08 ) transform = Transform( 0.93925, -0.342233, -0.0261794, -0.337317, -0.906276, -0.254719, 0.0634476, 0.248076, -0.966661, -0.933935, 0.609497, 0.0353355 )
visible = false visible = false
bone_name = "HandTip.R" bone_name = "HandTip.R"

View File

@ -43,21 +43,20 @@ bind/1/pose = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.693102, -1.13623, -1.5266
[sub_resource type="Animation" id=3] [sub_resource type="Animation" id=3]
resource_name = "ChestOpen" resource_name = "ChestOpen"
length = 0.333333
tracks/0/type = "transform" tracks/0/type = "transform"
tracks/0/path = NodePath("Geometry/Skeleton:Lid") tracks/0/path = NodePath("Geometry/Skeleton:Lid")
tracks/0/interp = 1 tracks/0/interp = 1
tracks/0/loop_wrap = true tracks/0/loop_wrap = true
tracks/0/imported = false tracks/0/imported = false
tracks/0/enabled = true tracks/0/enabled = true
tracks/0/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.0666667, 1, 0, 0, 0, 0, 0, -0.079364, 0.996846, 1, 1, 1, 0.133333, 1, 0, 0, 0, 0, 0, -0.489957, 0.871747, 1, 1, 1, 0.2, 1, 0, 0, 0, 0, 0, -0.855809, 0.517292, 1, 1, 1, 0.266667, 1, 2.37487e-08, 0, 0, 4.03449e-08, -3.99897e-08, 0.919654, -0.39273, 1, 1, 1, 0.333333, 1, 0, 0, 0, -1.45046e-08, 1.43769e-08, -0.808978, 0.587839, 1, 1, 1 ) tracks/0/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.7, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.8, 1, 0, 0, 0, 0, 0, -0.489957, 0.871747, 1, 1, 1, 0.9, 1, 0, 0, 0, 0, 0, -0.855809, 0.517292, 1, 1, 1, 1, 1, 0, 0, 0, -1.45046e-08, 1.43769e-08, -0.808978, 0.587839, 1, 1, 1 )
tracks/1/type = "transform" tracks/1/type = "transform"
tracks/1/path = NodePath("Geometry/Skeleton:Body") tracks/1/path = NodePath("Geometry/Skeleton:Body")
tracks/1/interp = 1 tracks/1/interp = 1
tracks/1/loop_wrap = true tracks/1/loop_wrap = true
tracks/1/imported = false tracks/1/imported = false
tracks/1/enabled = true tracks/1/enabled = true
tracks/1/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.133333, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.266667, 1, 0, 0, 0, -5.57256e-17, 1.47956e-08, -0.0876532, 0.996151, 1, 1, 1, 0.333333, 1, 0, 0, 0, -1.11023e-16, -2.8211e-10, 0.00209969, 0.999998, 1, 1, 1 ) tracks/1/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.7, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.8, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0.9, 1, 0, 0, 0, -5.57256e-17, 1.47956e-08, -0.0876532, 0.996151, 1, 1, 1, 1, 1, 0, 0, 0, -1.11023e-16, -2.8211e-10, 0.00209969, 0.999998, 1, 1, 1 )
tracks/2/type = "method" tracks/2/type = "method"
tracks/2/path = NodePath(".") tracks/2/path = NodePath(".")
tracks/2/interp = 1 tracks/2/interp = 1
@ -65,7 +64,7 @@ tracks/2/loop_wrap = true
tracks/2/imported = false tracks/2/imported = false
tracks/2/enabled = true tracks/2/enabled = true
tracks/2/keys = { tracks/2/keys = {
"times": PoolRealArray( 0.3, 1 ), "times": PoolRealArray( 1, 1.6 ),
"transitions": PoolRealArray( 1, 1 ), "transitions": PoolRealArray( 1, 1 ),
"values": [ { "values": [ {
"args": [ ], "args": [ ],

View File

@ -31,6 +31,8 @@ public class Tree : Entity, IInteractionInterface
Debug.Assert(_geometry != null); Debug.Assert(_geometry != null);
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer"); _animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
Debug.Assert(_animationPlayer != null); Debug.Assert(_animationPlayer != null);
_animationPlayer.CurrentAnimation = "Idle";
_animationPlayer.Play();
Connect("input_event", this, nameof(OnAreaInputEvent)); Connect("input_event", this, nameof(OnAreaInputEvent));
Connect("mouse_entered", this, nameof(OnAreaMouseEntered)); Connect("mouse_entered", this, nameof(OnAreaMouseEntered));
@ -87,12 +89,16 @@ public class Tree : Entity, IInteractionInterface
{ {
GD.Print("Starting tree animationplayer"); GD.Print("Starting tree animationplayer");
_animationPlayer.CurrentAnimation = "TreeShake"; _animationPlayer.CurrentAnimation = "TreeShake";
_animationPlayer.Seek(0);
_animationPlayer.Play(); _animationPlayer.Play();
_isBeingChopped = true; _isBeingChopped = true;
} }
public void OnInteractionEnd() public void OnInteractionEnd()
{ {
_animationPlayer.CurrentAnimation = "Idle";
_animationPlayer.Seek(0);
_animationPlayer.Stop(); _animationPlayer.Stop();
_isBeingChopped = false;
} }
} }

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://assets/KenneySurvivalKit/Models/foliage.material" type="Material" id=1] [ext_resource path="res://assets/KenneySurvivalKit/Models/foliage.material" type="Material" id=1]
[ext_resource path="res://assets/KenneySurvivalKit/Models/wood.material" type="Material" id=2] [ext_resource path="res://assets/KenneySurvivalKit/Models/wood.material" type="Material" id=2]
@ -39,8 +39,8 @@ height = 0.936801
[sub_resource type="PrismMesh" id=4] [sub_resource type="PrismMesh" id=4]
[sub_resource type="Animation" id=5] [sub_resource type="Animation" id=7]
resource_name = "TreeShake" resource_name = "Idle"
loop = true loop = true
tracks/0/type = "transform" tracks/0/type = "transform"
tracks/0/path = NodePath("Geometry") tracks/0/path = NodePath("Geometry")
@ -48,13 +48,69 @@ tracks/0/interp = 1
tracks/0/loop_wrap = true tracks/0/loop_wrap = true
tracks/0/imported = false tracks/0/imported = false
tracks/0/enabled = true tracks/0/enabled = true
tracks/0/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 1, 1.5, 0.5, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 0.6, 1.5, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 1, 1.5 ) tracks/0/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 1.00063, 1.49958 )
[sub_resource type="Animation" id=6]
length = 0.001
tracks/0/type = "bezier"
tracks/0/path = NodePath("Geometry:rotation_degrees:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"points": PoolRealArray( -10.23, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0 )
}
tracks/1/type = "bezier"
tracks/1/path = NodePath("Geometry:rotation_degrees:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"points": PoolRealArray( 0, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0 )
}
tracks/2/type = "bezier"
tracks/2/path = NodePath("Geometry:rotation_degrees:z")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/keys = {
"points": PoolRealArray( 0, -0.25, 0, 0.25, 0 ),
"times": PoolRealArray( 0 )
}
[sub_resource type="Animation" id=5]
resource_name = "TreeShake"
length = 0.8
loop = true
step = 0.05
tracks/0/type = "transform"
tracks/0/path = NodePath("Geometry")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = PoolRealArray( 0, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 1, 1.5, 0.3, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 1, 1.5, 0.301, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 0.671551, 1.46936, 0.302, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 0.647776, 1.48, 0.303, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 1, 1.5, 0.304, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 1.00045, 1.4997, 0.6, 1, 0, 0, 0, 0, 0, 0, 1, 1.5, 1, 1.5 )
tracks/1/type = "bezier"
tracks/1/path = NodePath("Geometry:rotation_degrees:x")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"points": PoolRealArray( 7.4006, -0.05, -6.00801, 0.05, 6.00801, 16.7033, -0.05, -0.232568, 0.05, 0.232568, -11.011, -0.05, -0.833332, 0.05, 0.833332, 7.7294, -0.05, 0.833333, 0.05, -0.833333, -5.77825, -0.05, 0.232568, 0.05, -0.232568, 4.10589, -0.05, 0.465136, 0.05, -0.465136, -0.157859, -0.1, 0, 0.1, 0 ),
"times": PoolRealArray( 0, 0.05, 0.15, 0.3, 0.4, 0.5, 0.6 )
}
[node name="Tree" type="KinematicBody"] [node name="Tree" type="KinematicBody"]
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="Geometry" type="MeshInstance" parent="."] [node name="Geometry" type="MeshInstance" parent="."]
transform = Transform( 1.5, 0, 0, 0, 1, 0, 0, 0, 1.5, 0, 0, 0 ) transform = Transform( 1.5, 0, 0, 0, 0.984722, 0.266325, 0, -0.177712, 1.47574, 0, 0, 0 )
mesh = SubResource( 1 ) mesh = SubResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="."] [node name="CollisionShape" type="CollisionShape" parent="."]
@ -78,4 +134,6 @@ mesh = SubResource( 4 )
skeleton = NodePath("../..") skeleton = NodePath("../..")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/Idle = SubResource( 7 )
anims/RESET = SubResource( 6 )
anims/TreeShake = SubResource( 5 ) anims/TreeShake = SubResource( 5 )

View File

@ -252,6 +252,11 @@ public class Game : Spatial
return; return;
} }
if (_player.InteractionComponent != null)
{
_player.InteractionComponent.EmitSignal("InteractionEnd");
}
_player.TaskQueueComponent.Reset(); _player.TaskQueueComponent.Reset();
_player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.NavigationTask( _player.TaskQueueComponent.Queue.Enqueue(new TaskQueueComponent.NavigationTask(
new NavigationComponent.NavigationPoint(tile.GlobalTranslation))); new NavigationComponent.NavigationPoint(tile.GlobalTranslation)));