瀏覽代碼

Update for Callable in NavigationAgent callbacks

Josh Jones 2 年之前
父節點
當前提交
8bfe0ee753

+ 1 - 3
tutorials/navigation/navigation_using_agent_avoidance.rst

@@ -50,9 +50,7 @@ To receive safe_velocity signals for avoidance for the agent a callback needs to
     extends Node3D
     
     var agent_rid : RID = NavigationServer3D.agent_create()
-    var agent_node3d : Node3D = self
-    var callback_function_name : StringName = "on_safe_velocity_computed"
-    NavigationServer3D.agent_set_callback(agent_rid, agent_node3d, callback_function_name)
+    NavigationServer3D.agent_set_callback(agent_rid, self.on_safe_velocity_computed)
     
     func on_safe_velocity_computed(safe_velocity : Vector3):
         # do your avoidance movement

+ 8 - 4
tutorials/navigation/navigation_using_navigationagents.rst

@@ -127,8 +127,10 @@ used to create or delete avoidance callbacks for the agent RID.
     extends NavigationAgent2D
 
     var agent : RID = get_rid()
-    NavigationServer2D::get_singleton()->agent_set_callback(agent, self, "_avoidance_done")
-    NavigationServer2D::get_singleton()->agent_set_callback(agent, null, "_avoidance_done")
+    # Enable
+    NavigationServer2D::get_singleton()->agent_set_callback(agent, self._avoidance_done)
+    # Disable
+    NavigationServer2D::get_singleton()->agent_set_callback(agent, Callable())
 
 .. tabs::
  .. code-tab:: gdscript GDScript
@@ -136,8 +138,10 @@ used to create or delete avoidance callbacks for the agent RID.
     extends NavigationAgent3D
 
     var agent : RID = get_rid()
-    NavigationServer3D::get_singleton()->agent_set_callback(agent, self, "_avoidance_done")
-    NavigationServer3D::get_singleton()->agent_set_callback(agent, null, "_avoidance_done")
+    # Enable
+    NavigationServer3D::get_singleton()->agent_set_callback(agent, self._avoidance_done)
+    # Disable
+    NavigationServer3D::get_singleton()->agent_set_callback(agent, Callable())
 
 NavigationAgent Script Templates
 --------------------------------