4.1 Navigation Avoidance seems to be trying to avoid non-existent obstacles
Asked Answered
C

1

0

I have been having an odd issue with the new obstacle avoidance in 4.1, but unfortunately, I'm not able to reproduce it in a minimal reproduction project. I'm not sure what's causing it, but here are a few details.

The navigation code isn't really doing anything fancy, just getting the direction to the next point, multiplying by the speed, setting the agent's velocity, then calling move_and_slide on the safe velocity that gets calculated.

The only navigation agent is the AI shown on the right side of the screen. There are no navigation obstacles when it shows this strange behavior. I have checked these with the NavigationServer2D.map_get_agents() / NavigationServer2D.map_get_obstacles() functions.

Here's the video of this happening:

untitled-project.mp4
17MB

Has anyone experienced something like this? Any ideas on how to create a minimal reproduction project if it does end up being a bug?

Thanks!

Contention answered 22/6, 2023 at 4:47 Comment(0)
C
0

OK, I have found a half solution, which is to turn off the navigation obstacle's avoidance_enabled before it gets freed. This does NOT work if you do it using

#this one doesn't work \/ \/
func _notification(what): 
    if what == NOTIFICATION_PREDELETE:
        avoidance_enabled = false

#this one does \/ \/
avoidance_enabled = false
queue_free()

I was able to reproduce it in a mrp and I'll put up an issue on github. Even though this solution works, it's definitely ideal, especially because you need to manually turn off the avoidance, which is especially anoying when you just want to reload the scene.

Contention answered 23/6, 2023 at 20:15 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.