-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
106 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
class_name NavigationVisualizer2D | ||
extends Line2D | ||
|
||
@export var enabled:bool | ||
@export var navigation_agent:NavigationAgent2D | ||
|
||
func set_enabled(value:bool)->void: | ||
enabled = value | ||
visible = enabled | ||
if enabled: | ||
if !navigation_agent.path_changed.is_connected(update_path): | ||
navigation_agent.path_changed.connect(update_path) | ||
else: | ||
if navigation_agent.path_changed.is_connected(update_path): | ||
navigation_agent.path_changed.disconnect(update_path) | ||
|
||
func _ready()->void: | ||
navigation_agent.path_changed.connect(update_path) | ||
top_level = true | ||
global_position = Vector2.ZERO | ||
set_enabled(enabled) | ||
|
||
func update_path()->void: | ||
points = navigation_agent.get_current_navigation_path() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class_name TargetAim | ||
extends Node | ||
|
||
@export var bot_input:BotInput | ||
@export var target_finder:TargetFinder | ||
## just point attack direction to the same direction as walking. | ||
@export var aim_walking_direction:bool | ||
|
||
func _ready()->void: | ||
target_finder.target_update.connect(on_target_update) | ||
|
||
func on_target_update()->void: | ||
if aim_walking_direction: | ||
bot_input.mover.input_resource.set_aim_direction((bot_input.mover.input_resource.axis * bot_input.axis_compensation).normalized()) | ||
return | ||
if target_finder.closest == null: | ||
return | ||
var direction:Vector2 = target_finder.closest.global_position - bot_input.global_position | ||
bot_input.mover.input_resource.set_aim_direction((direction * bot_input.axis_compensation).normalized()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters