GithubHelp home page GithubHelp logo

2d-liquid-simulator's Introduction

2D Liquid Simulator (In Godot Engine)

Originally created by Tterrasson (repository) and recreated by me, this plugin offers a set of three 2D nodes to simulate the behavior of liquids.

Warning

Although I have a version of this plugin for Godot 4.2, the next updates I release will often be for the newer version of Godot (4.3+), as it is tiring to change the code twice or more.

Tutorial

I recorded this video showing the simulator in operation and teaching how to use it. But I apologize, because in it I am limited to my mother tongue, Portuguese.

Documentation

The entire code API is documented and can be viewed in the Godot docs tab. If you have any difficulty with this, I recommend this video.

Documentation Picture

Who its work?

The LiquidServer stores the position of each instance of a Liquid and manages the flow of the quantity of each Liquid when necessary or requested by the API. When the flow stops permanently, LiquidServer stops running to increase performance.

It also decides when to update the Liquid sprite and checks when a cell is available or not.

Example Picture

Is it possible to detect collisions with a Liquid?

Yes, it is possible, but it comes at a performance cost, of course. Each Liquid cell is actually an instance of a packaged scene, so it can contain an Area2D, for example. But it is not recommended to transform a Liquid into some type of PhysicBody (this costs a lot of performance).

But a tip for this situation: if you are going to use Area2D, mark monitorable with false, leave it as a child of the Liquid sprite and make it a little smaller than it.

Example With Area2D Picture

Performance Guide

  • Small quadrants on LiquidServer equals more Liquid instances to render and process (i.e. less performance);
  • Higher values ​​of epsilon in LiquidServer will make the server stop faster, but will harm the horizontal distribution of Liquid;
  • Do not keep calling LiquidServer's start method too frequently, this may harm the server's automatic stop;
  • Combining shader + canvas group can give beautiful results, but it costs a lot of performance (The third example I left uses this);
  • Liquids that are in a long-lasting fall are automatically deleted by LiquidServer, and this can be configured in the max_falls variable. But even so, it is not recommended to place blocks outside the map.

Monitors

So that you can evaluate the performance of the simulation, some data is added to the Godot monitors tab.

Monitors Picture

2d-liquid-simulator's People

Contributors

l-marcel avatar

Stargazers

 avatar  avatar Masaharu Hosomichi avatar  avatar  avatar  avatar Sylvain Marty avatar  avatar Lyric Moysey-Rubin avatar ん. avatar  avatar  avatar Hyr avatar  avatar

Watchers

 avatar  avatar

Forkers

anu-prakash-dev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.