Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Navigation Polygon 2D' ported to Godot 4.1.1 #955

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

Alex2782
Copy link
Contributor

I have combined the script from the documentation with the old solution (click event with red dot)
https://docs.godotengine.org/en/latest/tutorials/navigation/navigation_introduction_2d.html#setup-for-2d-scene

Screen-2023-09-21-005207.mp4

'NavigationPolygon' drawn again, it looked buggy.
image

@Alex2782
Copy link
Contributor Author

how to fix these errors?

image

@Calinou
Copy link
Member

Calinou commented Sep 21, 2023

You have trailing whitespace (tabs) in your code. I recommend enabling the Trim Trailing Whitespace on Save editor setting to get rid of them automatically 🙂

@smix8
Copy link
Contributor

smix8 commented Sep 21, 2023

If we rework and update the demo maybe we should save the NavigationPolygon resource to an external file as a binary .res file?

Right now it is stored embedded as plain text inside the navigation.tscn file, something that we should not teach to new users as it will bloat their scene files and make them super slow to load/save/update on large and complex navigation meshes.

@Alex2782
Copy link
Contributor Author

@smix8
it's now an external file, but i forgot to configure properly to res, it's now tres (text), should we leave it like that? maybe better for github and debbugging? I don't know yet how to convert tres to res afterwards, does Godot already have a function for that?

Save as, or convert to function would perhaps be quite good in the context menu.
image

2d/navigation/character_navigation.gd Outdated Show resolved Hide resolved
2d/navigation/character_navigation.gd Outdated Show resolved Hide resolved
2d/navigation/character_navigation.gd Outdated Show resolved Hide resolved
2d/navigation/character_navigation.gd Outdated Show resolved Hide resolved
2d/navigation/character_navigation.gd Outdated Show resolved Hide resolved
2d/navigation/navigation.gd Outdated Show resolved Hide resolved
2d/navigation/navigation.gd Outdated Show resolved Hide resolved
2d/navigation/navigation.gd Outdated Show resolved Hide resolved
@smix8
Copy link
Contributor

smix8 commented Sep 21, 2023

don't know yet how to convert tres to res afterwards

Click the "Make Unique" again and "Save As" then you can save it as a new .res binary file.

2d/navigation/navigation.gd Outdated Show resolved Hide resolved
2d/navigation/navigation.gd Outdated Show resolved Hide resolved
@Alex2782
Copy link
Contributor Author

@smix8
The function set_movement_target was already in the character-GDscript, but unused (copied from the doc)
I moved the character to its own scene and deleted navigation.gd.

now only one script character.gd

navigation_agent.debug_enabled = true 👍

Screen-2023-09-21-235414.mp4

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on Godot 4.1.2, it works as expected.

Thanks!

@Calinou Calinou merged commit 647002a into godotengine:master Oct 17, 2023
1 check passed
@Alex2782 Alex2782 deleted the 2d-navigation-v4.1 branch October 18, 2023 00:17
@aaronfranke aaronfranke added this to the 4.1 milestone Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants