GithubHelp home page GithubHelp logo

nuverin / godot-floatable-body Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ueshita/godot-floatable-body

0.0 0.0 0.0 4.57 MB

A simple physics system where objects float on a fluid, for Godot Engine 4.

Home Page: https://godotengine.org/asset-library/asset/2345

License: MIT License

GDScript 100.00%

godot-floatable-body's Introduction

日本語

FloatableBody

Description

This is a simple physics system working on Godot Engine 4 that simulates the behavior of an object floating in a water-like fluid.

  • All buoyancy control code is written in GDScript.
  • Physics process are simplified, so it works well on mobile and web.
  • You can use either 3D or 2D.

Basic usage

Create a scene with a FluidArea3D node to represent underwater and a FloatableBody3D node to represent a floating object.

  1. Add a FluidArea3D node to the scene. This node inherits from Area3D, so add a CollisionShape3D to it as a child node and set the shape. I recommend adding a MeshInstance3D to make it visually compelling.
  2. Add a FloatableBody3D node to the scene. This node inherits from RigidBody3D, so add a CollisionShape3D as a child node to it and set the shape.
  3. Play the scene. The FloatableBody3D will fall down and enter the FluidArea3D and will be raised by buoyancy.

The above explanation is for 3D, but the procedure is the same for 2D.

Specification of parameters

Describes the parameters that are important for an FloatableBody3D/2D to float in water.

  • Density of FluidArea3D/2D.
    • The more fluid density you increase, the more buoyant the object will be.
  • Mass of RigidBody3D/2D.
    • The more you increase the object's mass, the less buoyant it will be.
  • Center of Mass of RigidBody3D/2D
    • The center of gravity of an object affects its stability. A ship, for example, will move more naturally if its center of mass is lowered.
  • Volume (Size, Radius, Height) of Shape3D/2D of CollisionShape3D/2D
    • The more you increase the volume of an object, the more buoyant it will be. Larger objects should be balanced by increasing their mass.
  • Fluid Damp of FloatableBody3D/2D.
    • The more resistance you increase, the harder it will be for the object to move in the fluid. If the resistance is too small, the object will move unnaturally, so increase the resistance to stabilize the object.

Advanced usage

For cases where you want to use buoyancy with CharacterBody3D/2D, use FluidInteractor3D/2D. This is the class used inside FloatableBody3D/2D.

There is FloatablePlayer3D/2D as a sample code. Please refer there for detailed usage.

Using Assets (Demo)

godot-floatable-body's People

Contributors

ueshita avatar

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.