Update waypoints demo
This commit is contained in:
parent
404c9274f9
commit
f776779175
|
@ -1,46 +0,0 @@
|
||||||
#*
|
|
||||||
#* play_animation.gd
|
|
||||||
#* =============================================================================
|
|
||||||
#* Copyright 2021-2023 Serhii Snitsaruk
|
|
||||||
#*
|
|
||||||
#* Use of this source code is governed by an MIT-style
|
|
||||||
#* license that can be found in the LICENSE file or at
|
|
||||||
#* https://opensource.org/licenses/MIT.
|
|
||||||
#* =============================================================================
|
|
||||||
#*
|
|
||||||
|
|
||||||
@tool
|
|
||||||
extends BTAction
|
|
||||||
|
|
||||||
@export var animation_name: String
|
|
||||||
@export var animation_player: NodePath
|
|
||||||
|
|
||||||
var _player: AnimationPlayer
|
|
||||||
var _finished: bool
|
|
||||||
|
|
||||||
|
|
||||||
func _generate_name() -> String:
|
|
||||||
return "PlayAnimation \"%s\"" % animation_name
|
|
||||||
|
|
||||||
|
|
||||||
func _setup() -> void:
|
|
||||||
_player = agent.get_node(animation_player)
|
|
||||||
|
|
||||||
|
|
||||||
func _enter() -> void:
|
|
||||||
if _player.has_animation(animation_name):
|
|
||||||
_finished = false
|
|
||||||
_player.play(animation_name)
|
|
||||||
_player.animation_finished.connect(_on_animation_finished, CONNECT_ONE_SHOT)
|
|
||||||
else:
|
|
||||||
_finished = true
|
|
||||||
|
|
||||||
|
|
||||||
func _tick(_delta: float) -> int:
|
|
||||||
if _finished:
|
|
||||||
return SUCCESS
|
|
||||||
return RUNNING
|
|
||||||
|
|
||||||
|
|
||||||
func _on_animation_finished(_anim):
|
|
||||||
_finished = true
|
|
|
@ -1,31 +0,0 @@
|
||||||
#*
|
|
||||||
#* start_animation.gd
|
|
||||||
#* =============================================================================
|
|
||||||
#* Copyright 2021-2023 Serhii Snitsaruk
|
|
||||||
#*
|
|
||||||
#* Use of this source code is governed by an MIT-style
|
|
||||||
#* license that can be found in the LICENSE file or at
|
|
||||||
#* https://opensource.org/licenses/MIT.
|
|
||||||
#* =============================================================================
|
|
||||||
#*
|
|
||||||
|
|
||||||
@tool
|
|
||||||
extends BTAction
|
|
||||||
|
|
||||||
@export var animation_name: String
|
|
||||||
@export var animation_player: NodePath
|
|
||||||
|
|
||||||
var _player: AnimationPlayer
|
|
||||||
|
|
||||||
|
|
||||||
func _generate_name() -> String:
|
|
||||||
return "StartAnimation \"%s\"" % animation_name
|
|
||||||
|
|
||||||
|
|
||||||
func _setup() -> void:
|
|
||||||
_player = agent.get_node(animation_player)
|
|
||||||
|
|
||||||
|
|
||||||
func _tick(p_delta: float) -> int:
|
|
||||||
_player.play(animation_name)
|
|
||||||
return SUCCESS
|
|
|
@ -1,7 +1,6 @@
|
||||||
[gd_resource type="BehaviorTree" load_steps=10 format=3 uid="uid://cjkqi41oagagd"]
|
[gd_resource type="BehaviorTree" load_steps=10 format=3 uid="uid://cjkqi41oagagd"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://ai/tasks/arrive_pos.gd" id="1_rhs33"]
|
[ext_resource type="Script" path="res://ai/tasks/arrive_pos.gd" id="1_rhs33"]
|
||||||
[ext_resource type="Script" path="res://ai/tasks/play_animation.gd" id="2_dg0ss"]
|
|
||||||
|
|
||||||
[sub_resource type="BTAction" id="BTAction_3xal7"]
|
[sub_resource type="BTAction" id="BTAction_3xal7"]
|
||||||
script = ExtResource("1_rhs33")
|
script = ExtResource("1_rhs33")
|
||||||
|
@ -9,16 +8,20 @@ target_position_var = "wp"
|
||||||
speed_var = "speed"
|
speed_var = "speed"
|
||||||
tolerance = 50.0
|
tolerance = 50.0
|
||||||
|
|
||||||
[sub_resource type="BTAction" id="BTAction_yq1vl"]
|
[sub_resource type="BBNode" id="BBNode_0t2vk"]
|
||||||
script = ExtResource("2_dg0ss")
|
resource_name = "AnimationPlayer"
|
||||||
animation_name = "bounce"
|
saved_value = NodePath("AnimationPlayer")
|
||||||
animation_player = NodePath("AnimationPlayer")
|
|
||||||
|
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_s01ov"]
|
||||||
|
await_completion = 1.0
|
||||||
|
animation_player = SubResource("BBNode_0t2vk")
|
||||||
|
animation_name = &"bounce"
|
||||||
|
|
||||||
[sub_resource type="BTWait" id="BTWait_qs55a"]
|
[sub_resource type="BTWait" id="BTWait_qs55a"]
|
||||||
duration = 0.1
|
duration = 0.1
|
||||||
|
|
||||||
[sub_resource type="BTSequence" id="BTSequence_a2ng0"]
|
[sub_resource type="BTSequence" id="BTSequence_a2ng0"]
|
||||||
children = [SubResource("BTAction_3xal7"), SubResource("BTAction_yq1vl"), SubResource("BTWait_qs55a")]
|
children = [SubResource("BTAction_3xal7"), SubResource("BTPlayAnimation_s01ov"), SubResource("BTWait_qs55a")]
|
||||||
|
|
||||||
[sub_resource type="BTForEach" id="BTForEach_0cp04"]
|
[sub_resource type="BTForEach" id="BTForEach_0cp04"]
|
||||||
children = [SubResource("BTSequence_a2ng0")]
|
children = [SubResource("BTSequence_a2ng0")]
|
||||||
|
|
Loading…
Reference in New Issue