Animate dungman
This commit is contained in:
parent
18925d3969
commit
a62d187626
Binary file not shown.
@ -1,9 +1,51 @@
|
|||||||
[gd_scene load_steps=8 format=2]
|
[gd_scene load_steps=17 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scripts/Player.gd" type="Script" id=1]
|
[ext_resource path="res://scripts/Player.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://assets/dungman/DungMan.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://assets/dungman/DungMan.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://assets/icons/stomach.png" type="Texture" id=3]
|
[ext_resource path="res://assets/icons/stomach.png" type="Texture" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id=10]
|
||||||
|
animation = "Blink"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeOneShot" id=11]
|
||||||
|
filter_enabled = true
|
||||||
|
filters = [ "Armature/Skeleton:Ear.L", "Armature/Skeleton:Ear.R", "Armature/Skeleton:Eye.L", "Armature/Skeleton:Eye.R", "Armature/Skeleton:Head", "Armature/Skeleton:Item" ]
|
||||||
|
mix_mode = 1
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id=12]
|
||||||
|
animation = "Idle-loop"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeAnimation" id=13]
|
||||||
|
animation = "Run-loop"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=14]
|
||||||
|
xfade_time = 0.3
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachineTransition" id=15]
|
||||||
|
xfade_time = 0.1
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachine" id=16]
|
||||||
|
states/idle/node = SubResource( 12 )
|
||||||
|
states/idle/position = Vector2( 357, 120.556 )
|
||||||
|
states/run/node = SubResource( 13 )
|
||||||
|
states/run/position = Vector2( 589, 121.667 )
|
||||||
|
transitions = [ "idle", "run", SubResource( 14 ), "run", "idle", SubResource( 15 ) ]
|
||||||
|
start_node = "idle"
|
||||||
|
graph_offset = Vector2( -115, -38 )
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeBlendTree" id=9]
|
||||||
|
graph_offset = Vector2( -451.163, 81.2997 )
|
||||||
|
nodes/Animation/node = SubResource( 10 )
|
||||||
|
nodes/Animation/position = Vector2( -200, 506.667 )
|
||||||
|
nodes/Blink/node = SubResource( 11 )
|
||||||
|
nodes/Blink/position = Vector2( 53.3333, 386.667 )
|
||||||
|
nodes/Move/node = SubResource( 16 )
|
||||||
|
nodes/Move/position = Vector2( -226.667, 240 )
|
||||||
|
nodes/output/position = Vector2( 546.667, 200 )
|
||||||
|
node_connections = [ "Blink", 0, "Move", "Blink", 1, "Animation", "output", 0, "Blink" ]
|
||||||
|
|
||||||
|
[sub_resource type="AnimationNodeStateMachinePlayback" id=17]
|
||||||
|
|
||||||
[sub_resource type="BoxShape" id=3]
|
[sub_resource type="BoxShape" id=3]
|
||||||
extents = Vector3( 0.25, 0.25, 1 )
|
extents = Vector3( 0.25, 0.25, 1 )
|
||||||
|
|
||||||
@ -26,6 +68,13 @@ script = ExtResource( 1 )
|
|||||||
|
|
||||||
[node name="DungMan" parent="." instance=ExtResource( 2 )]
|
[node name="DungMan" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="AnimationTree" type="AnimationTree" parent="DungMan"]
|
||||||
|
tree_root = SubResource( 9 )
|
||||||
|
anim_player = NodePath("../AnimationPlayer")
|
||||||
|
active = true
|
||||||
|
parameters/Blink/active = false
|
||||||
|
parameters/Move/playback = SubResource( 17 )
|
||||||
|
|
||||||
[node name="ItemSpawn" type="Spatial" parent="DungMan"]
|
[node name="ItemSpawn" type="Spatial" parent="DungMan"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6244, 0 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6244, 0 )
|
||||||
@ -40,6 +89,9 @@ collision_mask = 8
|
|||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.778807, 0.291356 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.778807, 0.291356 )
|
||||||
shape = SubResource( 3 )
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
|
[node name="blink_timer" type="Timer" parent="DungMan"]
|
||||||
|
autostart = true
|
||||||
|
|
||||||
[node name="CollisionShape" type="CollisionShape" parent="."]
|
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||||
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.641703, 0 )
|
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.641703, 0 )
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 2 )
|
||||||
@ -98,3 +150,7 @@ margin_left = 396.0
|
|||||||
margin_right = 524.0
|
margin_right = 524.0
|
||||||
margin_bottom = 128.0
|
margin_bottom = 128.0
|
||||||
texture = ExtResource( 3 )
|
texture = ExtResource( 3 )
|
||||||
|
|
||||||
|
[connection signal="timeout" from="DungMan/blink_timer" to="." method="_on_blink_timer_timeout"]
|
||||||
|
|
||||||
|
[editable path="DungMan"]
|
||||||
|
@ -7,16 +7,21 @@ export var inventory = { "ore" : 0 }
|
|||||||
var health: int = 4 setget set_health
|
var health: int = 4 setget set_health
|
||||||
|
|
||||||
var item_in_hand
|
var item_in_hand
|
||||||
|
onready var move_playback = $DungMan/AnimationTree["parameters/Move/playback"]
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
$hitbox.set_meta("owner", self)
|
$hitbox.set_meta("owner", self)
|
||||||
|
move_playback.travel("idle")
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
var input = Vector3(Input.get_axis("left", "right"), 0.0, Input.get_axis("up", "down"))
|
var input = Vector3(Input.get_axis("left", "right"), 0.0, Input.get_axis("up", "down"))
|
||||||
var motion = Plane.PLANE_XZ.project(get_viewport().get_camera().global_transform.basis.xform(input)).normalized() * SPEED
|
var motion = Plane.PLANE_XZ.project(get_viewport().get_camera().global_transform.basis.xform(input)).normalized() * SPEED
|
||||||
if motion.length_squared() > EPSILON:
|
if motion.length_squared() > EPSILON:
|
||||||
$DungMan.look_at(global_transform.origin - motion, Vector3.UP)
|
$DungMan.look_at(global_transform.origin - motion, Vector3.UP)
|
||||||
|
move_playback.travel("run")
|
||||||
|
else:
|
||||||
|
move_playback.travel("idle")
|
||||||
move_and_slide(motion)
|
move_and_slide(motion)
|
||||||
|
|
||||||
func set_health(new_value):
|
func set_health(new_value):
|
||||||
@ -108,3 +113,8 @@ func get_item_in_hand():
|
|||||||
if item_in_hand != null:
|
if item_in_hand != null:
|
||||||
item_to_return = drop_item_in_hand()
|
item_to_return = drop_item_in_hand()
|
||||||
return item_to_return
|
return item_to_return
|
||||||
|
|
||||||
|
|
||||||
|
func _on_blink_timer_timeout():
|
||||||
|
$DungMan/AnimationTree["parameters/Blink/active"] = true
|
||||||
|
$DungMan/blink_timer.wait_time = rand_range(0.5, 3.0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user