Animate dungman
This commit is contained in:
1 parent
18925d3969
commit
a62d187626
3 files changed
+67
-1
No files matched your search
@@ -7,16 +7,21 @@ export var inventory = { "ore" : 0 }
|
||||
var health: int = 4 setget set_health
|
||||
|
||||
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.
|
||||
func _ready():
|
||||
$hitbox.set_meta("owner", self)
|
||||
move_playback.travel("idle")
|
||||
|
||||
func _physics_process(delta):
|
||||
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
|
||||
if motion.length_squared() > EPSILON:
|
||||
$DungMan.look_at(global_transform.origin - motion, Vector3.UP)
|
||||
move_playback.travel("run")
|
||||
else:
|
||||
move_playback.travel("idle")
|
||||
move_and_slide(motion)
|
||||
|
||||
func set_health(new_value):
|
||||
@@ -108,3 +113,8 @@ func get_item_in_hand():
|
||||
if item_in_hand != null:
|
||||
item_to_return = drop_item_in_hand()
|
||||
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)
|
||||
Reference in new issue
Block a user