mirror of
https://github.com/godotengine/godot.git
synced 2024-12-03 17:42:12 +00:00
Merge pull request #48030 from smix8/issue_47337_broken_navagent2d_callback
This commit is contained in:
commit
bd7a92ec23
@ -35,6 +35,8 @@
|
||||
#include "servers/navigation_server_2d.h"
|
||||
|
||||
void NavigationAgent2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_rid"), &NavigationAgent2D::get_rid);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_target_desired_distance", "desired_distance"), &NavigationAgent2D::set_target_desired_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_target_desired_distance"), &NavigationAgent2D::get_target_desired_distance);
|
||||
|
||||
@ -88,9 +90,11 @@ void NavigationAgent2D::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_READY: {
|
||||
agent_parent = Object::cast_to<Node2D>(get_parent());
|
||||
|
||||
NavigationServer2D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done");
|
||||
|
||||
if (agent_parent != nullptr) {
|
||||
// place agent on navigation map first or else the RVO agent callback creation fails silently later
|
||||
NavigationServer2D::get_singleton()->agent_set_map(get_rid(), agent_parent->get_world_2d()->get_navigation_map());
|
||||
NavigationServer2D::get_singleton()->agent_set_callback(agent, this, "_avoidance_done");
|
||||
}
|
||||
set_physics_process_internal(true);
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
|
Loading…
Reference in New Issue
Block a user