All Projects → Yogoda → ZoneLoadingSystem

Yogoda / ZoneLoadingSystem

Licence: CC0-1.0 license
Dynamic zone loading system for Godot

Programming Languages

GDScript
375 projects

Projects that are alternatives of or similar to ZoneLoadingSystem

Godot FPC Base
A first person camera base project for Godot 3.x to help anyone get a jumpstart.
Stars: ✭ 39 (-71.53%)
Mutual labels:  godot, godot-engine
Project-Map
No description or website provided.
Stars: ✭ 52 (-62.04%)
Mutual labels:  godot, godot-engine
Game-Examples
Godot game examples for gotm.io - the Godot Platform!
Stars: ✭ 27 (-80.29%)
Mutual labels:  godot, godot-engine
novemberdev soulslike darksouls godot
Dark Souls clone in 3D with Godot
Stars: ✭ 51 (-62.77%)
Mutual labels:  godot, godot-engine
godot-awesome-splash
Collection of splash screens in Godot
Stars: ✭ 137 (+0%)
Mutual labels:  godot, godot-engine
godot-gdgifexporter
Gif exporter for Godot made entirely in GDScript
Stars: ✭ 85 (-37.96%)
Mutual labels:  godot, godot-engine
toziuha-night-oota
Opensource Metroidvania inspired on Castlevania Order of Ecclesia
Stars: ✭ 78 (-43.07%)
Mutual labels:  godot, godot-engine
nativelib-cli
NativeLib is a plugin management system for Godot engine.
Stars: ✭ 19 (-86.13%)
Mutual labels:  godot, godot-engine
GodotFAN
Facebook Audience Network Ad module for godot
Stars: ✭ 25 (-81.75%)
Mutual labels:  godot, godot-engine
godot-cpp-cmake
CMake scripts to build cross-platform GDNative C++ bindings
Stars: ✭ 20 (-85.4%)
Mutual labels:  godot, godot-engine
godot-lua-pluginscript
Godot PluginScript for the Lua language, currently based on LuaJIT's FFI
Stars: ✭ 182 (+32.85%)
Mutual labels:  godot, godot-engine
godot-admob-editor
This repository is for Godot's Addons to integrate natively AdMob to your Game Project without much configurations, with a beautiful UI and directly inside Godot Editor!
Stars: ✭ 43 (-68.61%)
Mutual labels:  godot, godot-engine
Godot-DialogPlugin
🗨️ A Dialog Node for Godot Engine
Stars: ✭ 194 (+41.61%)
Mutual labels:  godot, godot-engine
godot-cmvalley
Port of the Sauerbraten clanmap cm|Valley to Godot 4.0
Stars: ✭ 28 (-79.56%)
Mutual labels:  godot, godot-engine
godot-xterm
Terminal emulator for the Godot game engine.
Stars: ✭ 61 (-55.47%)
Mutual labels:  godot, godot-engine
Godot-Top-down-Shooter-Tutorial
This repository contains the source code for the Godot Top-down Shooter Tutorial series.
Stars: ✭ 41 (-70.07%)
Mutual labels:  godot, godot-engine
PimplePopper
Game to pop pimples using the awesome Godot Engine
Stars: ✭ 23 (-83.21%)
Mutual labels:  godot, godot-engine
godot-rpgdb
An easy to use JSON database-manager for Godot.
Stars: ✭ 25 (-81.75%)
Mutual labels:  godot, godot-engine
godot-android-plugin-firebase
Godot 3.2.2 Android plugin for Firebase
Stars: ✭ 41 (-70.07%)
Mutual labels:  godot, godot-engine
godot-portal-demo
Experimenting with portals in Godot Engine
Stars: ✭ 66 (-51.82%)
Mutual labels:  godot, godot-engine

Zone Loading System

This template shows you how your game can automatically load/unload zones according to your player position. By implementing this template in your game you can have a seamless world as big as needed, without loading screens.

This works for both 2D games and 3D games, try the demo by executing this project.

Note that it is not a chunk system based on distance to the player, if you need chunks loading for an open world, please check other solutions.

Test image

Pros

  • Good if loading the whole world at once would take too much time/memory.
  • Allows huge seamless worlds without loading screen.
  • Works for 2D and 3D.

Cons

  • Useless if your whole world can be quickly loaded in memory, or if you don't mind loading screens.
  • Need to manually split the game world into zones and set triggers.
  • In 3D, zones need to be carfully designed so that player cannot see unloaded zones (needs twists and turns or fog).

How does it work ?

The geometry/sprites of each zone sits inside an area node that should encompass all the zone geometry/sprites. The zones areas should be overlapping.

Rules:

  • The player can be in one or more zones at the same time (player zone(s)).
  • Zones overlapping the player zone(s) are automatically preloaded (loaded but not attached to the game tree).
  • When the player enters a new zone, that zone is attached to the tree (made visible).
  • When the player exits a zone, that zone is detached from the tree (invisible, but stays loaded).
  • Zones not direcly overlapping the player zone(s) are unloaded (freed from memory).
  • Zones are detached with a small delay (a few seconds) to prevent unnecessary work when player moves back and forth a small amount.

Background loading

All the loading and instancing is done by one background thread that runs parallel to the main game, so it should not create stutters, please check "background_loader.gd".

The thread is automatically started at the start of the game, and stopped at the end. Stopping the thread can take a few seconds if the thread is currently loading data.

Configure the player

  • For 2D, add an Area2D to your player's camera with a collision shape covering the whole screen. This way zones will be loaded when they become visible on screen.
  • For 3D, add an Area to your player's camera with a collision shape encompassing the player.
  • Set the area's collision mask to "zone_triggers" (leave collision layer empty), this way the area will collide only with zone triggers.
  • Assign your player scene to the world's "Player Scene" attribute, it will be automatically spawned on world load, at the location of a node in the group PLAYER_SPAWN.

Add a new zone

  • Create a zone, save it as a separate scene.
  • Create a new node under World/ZoneLoader, name it with your zone name.
  • Attach the script zone.gd to the node
  • Set the zone path in the inspector
  • Click the checkbox "Preview" to make the zone visible
  • Move the zone node where you want it to be relative to the other zones
  • Add a new Area (or Area2D) node as child, name it ZoneTrigger
  • Set the collision layer and mask to zone_triggers
  • Add one or more collision shapes that encompasses the zone, the zone will be loaded when the player enters this area

Done. Now the zone will be loaded, instanced and attached to the tree automatically by the system.

Known issues

Stutter when a new zone is attached to the tree

  • New shaders are being compiled. Limit the number of different shader you use and use a shader cache to precompile the shaders during loading screen.
  • outputting to the console using print() and errors can create stutters.

Error: _body_enter_tree: Condition "!E" is true (fixed in Godot 3.4 beta 4!).

  • Can happen when exiting and reentering a zone in 3D, this is a bug in Godot before 3.4 beta 4.

Objects/monsters are reset when going back

  • You need to save your zone data when it is unloaded and restore it when the zone is loaded, it is not in the scope of this template.

Contribute

You can leave comments here: #3

You are free to submit issues, contribute and improve this template, this is a Creative Commons

Big thanks to rmvermeulen, Wrzlprnft and jbpuryear for their contributions!

Test image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].