Git Product home page Git Product logo

godot-rope3d's Introduction

Godot Rope3D

Physical 3D rope based on PinJoint3D that interacts with RigidBody3D

bc55450e-cf9b-4038-8c1b-3eb9aa2e3154

Installation

Via asset library

Usage

GUI

  • Instantiate child scene. Adding child node will not work because Rope3D scene has children
  • click Rope3D
  • Select start point, end point, adjust other values
  • Reference the Rope3D node in code, call rope.make() when you need it

Code

const RopeScene: PackedScene = preload("res://addons/rope3d/Rope3D.tscn")

@onready var start_point = $RigidBody/Node3D
@onready var end_point = $AnotherRigidBody/AnotherNode3D


func _ready():
	var rope = RopeScene.instantiate()
	rope.start_point = start_point
	rope.end_point = end_point
	rope.rope_length = 6.0
	rope.resolution = 6.0   # number of pinjoints
	rope.radius = 0.1
	
	var ok = rope.can_make()
	if ok:
		add_child(rope)
		rope.make()

Rope Making Fails

Due to dynamic generating, there are many situations that rope.make() can raise errors

  • The rope_length is shorter then distance between two Node3Ds
  • resolution cannot be less then one
  • The size of segment is longer than the rope
  • Two global positions of Node3D and the turning point position cannot constitude to a triangle, as shown in the figure below

dynamic_rope_3

If you want to make gameplays that allows player to create rope on the fly, make sure to check the boolean result of rope.make() or rope.can_make()

Without Physics

If you do not need physics, you can simply instantiate a RopeMesh and operate the curve points of the child Path3D

RopeMesh is an ImmediateMesh that draws a 3d rope from Path3D

verlet rope C#, ImmediateMesh rope with particle verlet integration simulation, is highly recommended if you don't need RigidBody3D interaction and use C# for your project.

How it works

Dynamic 3D Physical Rope in Godot

godot-rope3d's People

Contributors

portwatcher avatar

Stargazers

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

Watchers

 avatar  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.