diff options
Diffstat (limited to 'scene/2d/navigation_agent_2d.h')
-rw-r--r-- | scene/2d/navigation_agent_2d.h | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h index 26eccfc949..052cd78a56 100644 --- a/scene/2d/navigation_agent_2d.h +++ b/scene/2d/navigation_agent_2d.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -31,38 +31,37 @@ #ifndef NAVIGATION_AGENT_2D_H #define NAVIGATION_AGENT_2D_H -#include "core/vector.h" #include "scene/main/node.h" class Node2D; -class Navigation2D; class NavigationAgent2D : public Node { GDCLASS(NavigationAgent2D, Node); - Node2D *agent_parent; - Navigation2D *navigation; + Node2D *agent_parent = nullptr; RID agent; - real_t target_desired_distance; + uint32_t navigable_layers = 1; + + real_t target_desired_distance = 1.0; real_t radius; real_t neighbor_dist; int max_neighbors; real_t time_horizon; real_t max_speed; - real_t path_max_distance; + real_t path_max_distance = 3.0; Vector2 target_location; Vector<Vector2> navigation_path; int nav_path_index; - bool velocity_submitted; + bool velocity_submitted = false; Vector2 prev_safe_velocity; /// The submitted target velocity Vector2 target_velocity; - bool target_reached; - bool navigation_finished; + bool target_reached = false; + bool navigation_finished = true; // No initialized on purpose uint32_t update_frame_id; @@ -74,18 +73,13 @@ public: NavigationAgent2D(); virtual ~NavigationAgent2D(); - void set_navigation(Navigation2D *p_nav); - const Navigation2D *get_navigation() const { - return navigation; - } - - void set_navigation_node(Node *p_nav); - Node *get_navigation_node() const; - RID get_rid() const { return agent; } + void set_navigable_layers(uint32_t p_layers); + uint32_t get_navigable_layers() const; + void set_target_desired_distance(real_t p_dd); real_t get_target_desired_distance() const { return target_desired_distance; @@ -141,10 +135,11 @@ public: void set_velocity(Vector2 p_velocity); void _avoidance_done(Vector3 p_new_velocity); - virtual String get_configuration_warning() const; + TypedArray<String> get_configuration_warnings() const override; private: void update_navigation(); + void _check_distance_to_target(); }; #endif |