NavigationAgent's "link_reached" signal details should be improved #6167
venilark
started this conversation in
Engine Core
Replies: 2 comments 4 replies
-
The function Also @DarkKilauea. |
Beta Was this translation helpful? Give feedback.
2 replies
-
@venilark Please see pr godotengine/godot#73229 and let us know if this can solve this issue here. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When setting up the NavigationLink3D, start position and end position are in relation to the NavigationLink3D itself, not global coordinates. When we get the details in the signal, we get the global coordinates of the current part of the link we are stepping on, whether it's start pos or end pos, so I did this
var link: MyJumpLink = details["owner"] as MyJumpLink

var node_position: int = link.get_node_position(details.location)
(this is the custom MyJumpLink class that extends NavigationLink3D)
but didn't work because the signal returns the closest point intersecting the Navmesh, not the object we set up manually
The code returns -1 because it is not exact enough so then I did this
if current_node_position.distance_to(start_node_position) < 0.5:
return 0
elif current_node_position.distance_to(end_node_position) < 0.5:
return 1
return -1
then if we need to get the other end (as a landing point for example)
func get_node_position_other_end(current_position: int) -> Vector3:
match current_position:
0:
return get_end_position()
_:
return get_start_position()
func get_end_position() -> Vector3:
return to_global(end_location)
func get_start_position() -> Vector3:
return to_global(start_location)
while this is working, I think it would be a good idea to add more parameters to the signal, so we know which part of the link we have reached, like "link_position_reached": "start"/"end", this way we could get the other one simply with the last two functions, without bothering about anything else
Also the signal documentation says
This is confusing, because if a link is bidirectional, you could be on the "end"
Beta Was this translation helpful? Give feedback.
All reactions