gdquest-demos / godot-platformer-2d

2d Metroidvania-inspired game for the 2019 GDquest Godot Kickstarter course project.
MIT License
623 stars 74 forks source link

Heatmap pathfinding for many agents #165

Closed Razoric480 closed 5 years ago

Razoric480 commented 5 years ago

Populates a grid that uses razcore's pathfinder class to build a heatmap - each tile referring to how far away they are from the goal. Uses a simple extra thread to keep the game from hitching up. Spawner creates some 500 heatmap following enemies that use as simple a set of nodes and code as possible to show off performance.

Currently, the enemies don't interact with the player - not sure how well it'd do with physics based collision detection with that many agents.

Note: I also built it using GDNative, but the performance gain was so minimal - just barely any faster using C++ for loops, since the biggest cost is actually in the calls to Astar.find_path(). It's a testament to how well GDScript can work.

Razoric480 commented 5 years ago

Two commits is a bit of a git snafu that I wasn't sure how to fix. T_T

Hahem - floodfilling should be working and the pathfinding is doing okay. There's some bugs near the edges (like if you go to the very top of the map) where some of the agents get stuck. It is working off of GDNative code, so it'll need to be compiled to libheatmap.dll/.so/.dylib in the win64/x11/osx folders under /assets/libraries/. At least, that's how I configured it for the the .gdnlib file.

NathanLovato commented 5 years ago

It's looking good!

Could you add godot_headers as a git submodule, checked out to the right godot version, so everyone can easily build the gdnative code?

https://github.com/GodotNativeTools/godot_headers

Also, do you mind adding a short "building" section in the README, e.g. with the commands you use on Windows? I'll add the ones for linux - I guess we can use gcc here

Razoric480 commented 5 years ago

Certainly. Will do that.

Razoric480 commented 5 years ago

I think that's all correct. Let me know if I did it wrong - haven't really played with submodules before.

NathanLovato commented 5 years ago

Looking good. Are the big .gitignore and the .vcxproj files necessary? For ignores specific to your copy of the project, you can use git's exclude feature. It's in .git/info/exclude iirc. This way, we don't need gitignore rules for everyone's setup

Razoric480 commented 5 years ago

Yeah, I've been using exclude a bit.

As for visual studio, the vcxproj files are required (the solution (SLN) contains the projects (VCxproj/vcxproj.filters) which contain the configurations). There's a vcxproj.user which isn't included.

The gitignore could probably be omitted, however.

NathanLovato commented 5 years ago

Got it. Could you remove the .gitignore? And I'll merge (first-hand tomorrow morning)

Razoric480 commented 5 years ago

Done and done.

NathanLovato commented 5 years ago

Merci beaucoup. 🙂