Adds enemies
This commit is contained in:
parent
cf8ba8bacb
commit
76e5b1927f
324 changed files with 28447 additions and 106 deletions
32
demo/ai/tasks/face_target.gd
Normal file
32
demo/ai/tasks/face_target.gd
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#*
|
||||
#* face_target.gd
|
||||
#* =============================================================================
|
||||
#* Copyright (c) 2023-present Serhii Snitsaruk and the LimboAI contributors.
|
||||
#*
|
||||
#* 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
|
||||
## Flips the agent to face the target, returning [code]SUCCESS[/code]. [br]
|
||||
## Returns [code]FAILURE[/code] if [member target_var] is not a valid [Node2D] instance.
|
||||
|
||||
## Blackboard variable that stores our target (expecting Node2D).
|
||||
@export var target_var: StringName = &"target"
|
||||
|
||||
# Display a customized name (requires @tool).
|
||||
func _generate_name() -> String:
|
||||
return "FaceTarget " + LimboUtility.decorate_var(target_var)
|
||||
|
||||
|
||||
# Called each time this task is ticked (aka executed).
|
||||
func _tick(_delta: float) -> Status:
|
||||
var target: Node2D = blackboard.get_var(target_var)
|
||||
if not is_instance_valid(target):
|
||||
return FAILURE
|
||||
var dir: float = target.global_position.x - agent.global_position.x
|
||||
agent.velocity = Vector2.ZERO
|
||||
agent.face_dir(dir)
|
||||
return SUCCESS
|
||||
Loading…
Add table
Add a link
Reference in a new issue