godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.12k stars 20.2k forks source link

Debug window closes with no error when setting navmesh on navigation region 3d #78619

Closed liabilityluke closed 1 year ago

liabilityluke commented 1 year ago

Godot version

4.1 beta 3

System information

Windows 11

Issue description

I have a simple navigation scene (that I was originally creating to try to reproduce a different bug), but when code that sets the navigation mesh on the navigation region runs, it closes the debug window (or whatever the window the game runs in is called) with no error.

Steps to reproduce

Here is the code on my NavigationRegion3D node -

extends NavigationRegion3D

@export var test := false

func _ready() :
    if generate_mesh :
        print("before generating mesh")
        var _navigation_mesh := NavigationMesh.new()
        var outline = PackedVector3Array([Vector3(-3.5, 0, -3.5), Vector3(-3.5, 0, 3.5), Vector3(3.5, 0, 3.5), Vector3(3.5, 0, -3.5)])
        _navigation_mesh.set_vertices(outline)
        _navigation_mesh.add_polygon([1,2,3,4])
        navigation_mesh = _navigation_mesh
        print("after generating mesh")

I have found through playing with breakpoints that the problem is definetely coming from the line navigation_mesh = _navigation_mesh

Minimal reproduction project

Navigation Mesh MRP.zip

liabilityluke commented 1 year ago

Ok, It turns out I just forgot to zero index the indices when adding them to the list, but I still feel like it's a bug that it doesn't throw any errors?