You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could be a useful addition to the list of Components...
Previously written code for 2D version:
@icon("../../module.svg")
extendsNavigationAgent2Dclass_nameNavigationComponent2D## Component for simplifying the use of the NavigationAgent2D.#### @experimental@exportvarvelocity_component : VelocityComponent2D## Minimum distance from the target position.@exportvarmin_target_dist:=3.0## Speed at which the agent must slowdown when reaching the target.@exportvarslowdown_rate:=1.0## Target node to follow (Follows global position).@exportvartarget : Node2Dfunc_ready() ->void:
if (!velocity_component):
printerr("Missing velocity component on "+name+" in "+owner.name)
func_process(_delta: float) ->void:
if (target):
target_position=target.global_positionfuncget_target_dir() ->Vector2:
vardir= (target_position-owner.global_position).normalized()
returndirfuncget_next_pos_dir() ->Vector2:
vardir= (get_next_path_position() -owner.global_position).normalized()
returndirfuncfollow_path():
if (distance_to_target() <min_target_dist):
velocity_component.slowdown(slowdown_rate)
print("wo")
returnvelocity_component.max_velocity(get_next_pos_dir())
set_velocity_forced(velocity_component.velocity)
print(velocity)
The text was updated successfully, but these errors were encountered:
Could be a useful addition to the list of Components...
Previously written code for 2D version:
The text was updated successfully, but these errors were encountered: