Giter VIP home page Giter VIP logo

gdnative-ropesim's Introduction

GDNative Ropesim

A 2D verlet integration based rope simulation for Godot 4.2.

The computation-heavy simulation part is written in C++ using GDExtension, the rest in GDScript. This allows for fast processing and easy extendability, while keeping the code readable.

The last Godot 3.x version can be found on the 3.x branch, however, this branch will no longer receive updates.

Setup

  1. Get the addon
    • Download from the asset store, or
    • Download the latest release from the release page, or
    • Download it from the latest GitHub Actions run, or
    • Compile it yourself.
  2. Copy or symlink addons/ropesim to your project's addons/ directory
  3. Enable the addon in the project settings
  4. Restart Godot

Building

First, clone or download the repository and run git submodule update --init --recursive.

See here on how to create and compile GDExtension libraries.

To compile for Linux, run the following commands. Compiling for other platforms works analogously.

$ scons target=template_release platform=linux arch=x86_64 -j8
$ scons target=template_debug platform=linux arch=x86_64 -j8

Output files are saved to demo/addons/ropesim/bin/.

Documentation

Following nodes exist:

  • Rope: The basic rope node. Optionally renders the rope using draw_polyline().
  • RopeAnchor: Always snaps to the specified position on the target rope. Optionally, also adapts to the rope's curvature. Can be used to attach objects to a rope.
  • RopeHandle: A handle that can be used to control, animate, or fixate parts of the rope.
  • RopeRendererLine2D: Renders a target rope using Line2D.
  • RopeCollisionShapeGenerator: Can be used e.g. in an Area2D to detect collisions with the target rope.

See inline comments for further information and documentation of node properties.

The included demo project and the showcase video below provide some usage examples.

When one of these nodes is selected, a "Ropesim" menu appears in the editor toolbar that can be used to toggle live preview in the editor on and off.

All rope related tools, automatically pause themselves when their target rope is paused to save performance.

Showcase

A quick overview of how to use each node.

ropesim_showcase.mp4

Jellyfish with rope simulated tentacles.

jelly.final_4M.mp4

gdnative-ropesim's People

Contributors

mphe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

yangqingming

gdnative-ropesim's Issues

Problem with Android

I attempted to execute an Android version on my mobile device, but encountered an issue with the rope not rendering correctly. Upon inspecting the build console, I identified the following error message:

Can't open file from path 'res://addons/ropesim/bin/libropesim.android.template_debug.arm64.so'.
Parser Error: Identifier "NativeRopeServer" not declared in the current scope.

I saw that there are steps in the GitHub Actions for generating Android files: here. So I'm not sure about the cause of my error. Are there any specific guidelines or tricks to successfully get an Android build? I use the GUI godot exporter to directly run on my phone. and the addon is installed from godot AssetLib.

Thanks in advance :)

Web Export Support

Hi, I was using your addon and it worked great, until I tried using it in my web export and it resulted in the following error message:

No suitable library found for GDExtension: res://addons/ropesim/libropesim.gdextension. Possible feature flags for your platform: web, s3tc, wasm32, template, debug, template_debug

My game still ran but just with the ropes non-existent. I tried building my own library with the template for web into wasm files and I added these lines into the gdextension file:

web.debug.wasm = "res://addons/ropesim/bin/libropesim.web.template_debug.wasm32.a"
web.release.wasm = "res://addons/ropesim/bin/libropesim.web.template_release.wasm32.a"

But it still didn't work, so I was wondering if there will be any support for web or if its just a limitation of the Godot engine.

Outdated macOS build

The macOS build currently only targets x86_64 architecture. Adding an arm64 binary or replacing the current x86_64 binary with Universal 2 is necessary for it to run on macs from 2021 onwards.

Collision with staticbodies

I was wondering if there was a way to collide with staticbodies? I'd like to use the rope as a tail for a character that drags along the floor, but i cant find any collision settings. Is this planned / implemented yet?

Gravity should be a Vector2

Currently gravity is a float. Some games like to change the direction of gravity for various reasons.

Alternatively, to not break compatibility, an additional gravity_direction vector can be provided. It might also be worthwhile to just grab gravity from the physics engine itself instead using its own specific gravity value.

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.