Skip to content

Commit

Permalink
Loop barista walking
Browse files Browse the repository at this point in the history
  • Loading branch information
outfrost committed Oct 17, 2021
1 parent 263b748 commit cb89a1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
15 changes: 13 additions & 2 deletions character/Barista.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const ACCEL_RATE: float = 2.0

export var max_speed: float = 3.0

onready var anim = $baristaLowPoly/AnimationPlayer

onready var navmesh: Navigation = get_parent().find_node("Navigation")
onready var y_pos: float = transform.origin.y

Expand All @@ -21,13 +23,22 @@ var current_speed: float = 0.0
var path = []
var path_node = 0

func _ready() -> void:
anim.get_animation("walkFast").loop = true
anim.get_animation("walkFastCarrying").loop = true

# Starting pose: end of walk cycle
anim.play("walkFast")
anim.seek(anim.current_animation_length, true)
anim.stop(false)

func _physics_process(delta):
match current_state:
State.Idle:
if path_node < path.size():
current_state = State.Walking
var animation_name = "walkFast" if is_emptyhanded() else "walkFastCarrying"
$baristaLowPoly/AnimationPlayer.play(animation_name)
anim.play(animation_name, -1.0, max_speed)
State.Walking:
if path_node < path.size():
var move: Vector3 = path[path_node] - global_transform.origin
Expand All @@ -41,7 +52,7 @@ func _physics_process(delta):
rotation.y = lerp(rotation.y, atan2(direction.x, direction.z), 0.1)
else:
current_state = State.Idle
$baristaLowPoly/AnimationPlayer.stop()
anim.stop()
emit_signal("done_walking")
State.Busy:
pass
Expand Down
7 changes: 1 addition & 6 deletions character/PlayerVisual.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=5 format=2]

[ext_resource path="res://art_assets/barista_textured/baristaLowPoly.gltf" type="PackedScene" id=1]
[ext_resource path="res://art_assets/barista_textured/baristaToScale.gltf" type="PackedScene" id=2]
[ext_resource path="res://character/Barista.gd" type="Script" id=3]
[ext_resource path="res://game/cup/Cup.tscn" type="PackedScene" id=4]

Expand All @@ -15,10 +14,6 @@ max_speed = 2.0
[node name="baristaLowPoly" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.6, 0 )

[node name="baristaToScale" parent="." instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.6, 0 )
visible = false

[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.3, 0 )
shape = SubResource( 1 )
Expand Down

0 comments on commit cb89a1f

Please sign in to comment.