Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/poohcom1/godot-level-graph
Godot addon for managing loosely connected levels.
https://github.com/poohcom1/godot-level-graph
godot godot-addon
Last synced: 29 days ago
JSON representation
Godot addon for managing loosely connected levels.
- Host: GitHub
- URL: https://github.com/poohcom1/godot-level-graph
- Owner: poohcom1
- Created: 2024-07-31T18:02:00.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-09-26T11:01:09.000Z (about 1 month ago)
- Last Synced: 2024-09-29T04:07:22.720Z (about 1 month ago)
- Topics: godot, godot-addon
- Language: GDScript
- Homepage:
- Size: 187 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Godot Level Graph
A Godot addon for level organization and room transitions using Area2D nodes, inspired by Nathan Hoad's [Location Manager](https://www.youtube.com/watch?v=_l3yTp9JOOg).
Designed specifically for 2D side-scrollers and metroidvanias with loosely connected rooms as opposed to a strict grid-like map.
This is a mirror of the addon in my game project, so I won't be actively maintaining it. Feel free to fork and upload to the asset library if you want.
![Preview](.github/preview.png)
## Setup
1. Copy the `addons/level_graph` folder to your project's `addons` folder.
2. Enable the plugin in the project settings.
3. In your project settings, set `Level Graph > General > Root Directory` to a folder where your level scenes will be stored.
4. Add `Exit` nodes into your scenes to define the room transitions.
5. Go to the `Level` editor tab and select `Reload levels`.
6. Connect your levels using the `Connect` button.
7. Setup your code. Use the `LevelGraph` singleton to get information about the levels and exits.```gdscript
# player.gd - Must be a body or areafunc _ready():
await get_tree().create_timer(0.5).timeout # Prevent looping as the player touches the exit. Change this code to something more robust like waiting for the enter animation to finish
LevelGraph.set_player(self)# stage_manager.gd - Whatever script you want to manage level changes
func _ready() -> void:
LevelGraph.level_changed.connect(_on_level_change)func _on_level_change(from_level: String, from_exit: int) -> void:
var exit: Exit = await LevelGraph.get_exit_node_in_level(from_exit)
player.leave_level(exit.orientation) # For animating exitvar dest: Dictionary = LevelGraph.get_destination(from_level, from_exit)
get_tree().change_scene_to_file(dest["level"]) # Or whatever method you use to transition scenesvar entry: Exit = await LevelGraph.get_exit_node_in_level(dest["exit"])
player.global_position = LevelGraph.get_exit_node_spawn_position(entry) # Uses the Exit's raycast to find the ground position when the Exit is Left/Right
player.enter_level(entry.orientation) # For animating entry
```## API
- `LevelGraph`: Singleton for getting level information.
- `Exit`: An area 2D node that triggers a room transition when the player collides with it.
- `LevelGraph.Orientation`: Cosmetic value set on an Exit node, represented by the arrow on the level editor. Has no affect on transitions, but useful for getting the direction to animate player walking in/out or levels.
- `LevelGraph.VerticalDirection`: Cosmetic value set on an Exit node. Direction of the player when the exit is `Top` or `Bottom`. Can be used to set the facing direction of the player jumping/falling into levels.## Settings
| Setting | Description |
| ------------------- | ---------------------------------------------------------------------------------- |
| Root Directory | The folder where your level scenes are stored. Set this to speed up level loading. |
| Group Levels | Group levels in the editor by parent directory. |
| Auto refresh levels | Automatically reload levels on save. |