Basic platformer with rope

This commit is contained in:
ASOwnerYT
2026-07-25 16:10:50 +12:00
commit 4818002bbd
503 changed files with 16081 additions and 0 deletions
@@ -0,0 +1,8 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://b3uxs3oppo8yg"]
[ext_resource type="Texture2D" uid="uid://35sytdecvva" path="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Dark/texture_09.png" id="1_f116y"]
[resource]
albedo_texture = ExtResource("1_f116y")
uv1_triplanar = true
uv1_world_triplanar = true
@@ -0,0 +1,7 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://d3du70wkvp1eo"]
[ext_resource type="Texture2D" uid="uid://cm23wh7dgtjxu" path="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Dark/texture_08.png" id="1_2upd1"]
[resource]
albedo_texture = ExtResource("1_2upd1")
uv1_triplanar = true
@@ -0,0 +1,8 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://esbif4ec2kcc"]
[ext_resource type="Texture2D" uid="uid://crssf8e2w5f38" path="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Green/texture_09.png" id="1_harec"]
[resource]
albedo_texture = ExtResource("1_harec")
uv1_scale = Vector3(2, 2, 2)
uv1_triplanar_sharpness = 150.0
@@ -0,0 +1,8 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://cla83y5h0026e"]
[ext_resource type="Texture2D" uid="uid://bt2p2d2qwh2f2" path="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Light/texture_07.png" id="1_00evc"]
[resource]
albedo_texture = ExtResource("1_00evc")
uv1_scale = Vector3(2, 2, 2)
uv1_triplanar_sharpness = 150.0
@@ -0,0 +1,8 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://br633ah53wtim"]
[ext_resource type="Texture2D" uid="uid://cp8kfufswmmmc" path="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Orange/texture_09.png" id="1_sc217"]
[resource]
albedo_texture = ExtResource("1_sc217")
uv1_scale = Vector3(2, 2, 2)
uv1_triplanar_sharpness = 150.0
@@ -0,0 +1,8 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://de64w7g55hbby"]
[ext_resource type="Texture2D" uid="uid://5eqshu0hyxfn" path="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Purple/texture_09.png" id="1_hwk3o"]
[resource]
albedo_texture = ExtResource("1_hwk3o")
uv1_scale = Vector3(2, 2, 2)
uv1_triplanar_sharpness = 150.0
@@ -0,0 +1,8 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://c0vdiomofi8ro"]
[ext_resource type="Texture2D" uid="uid://ccaemffwu4u4r" path="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Red/texture_09.png" id="1_kfh5t"]
[resource]
albedo_texture = ExtResource("1_kfh5t")
uv1_scale = Vector3(2, 2, 2)
uv1_triplanar_sharpness = 150.0
+127
View File
@@ -0,0 +1,127 @@
extends Path3D
# Script by Elijah Martin/Palin_drome
@export_range(3,200,1) var number_of_segments = 10
@export_range(3,50,1) var mesh_sides = 6
@export var cable_thickness = 0.1
@export_range(0.0, 0.99, 0.01) var joint_bias_or_stiffness = 0.2
@export_range(0.0, 64.0, 0.1) var max_impulse = 2.0
@export_range(0.0, 100.0, 0.1,"0 to disable to 100 to make completely stable") var physics_dampening = 0.5
@export var cable_segment_mass = 2.0
@export var fixed_start_point = true
@export var fixed_end_point = true
@export var rigidbody_attached_to_start : RigidBody3D
@export var rigidbody_attached_to_end : RigidBody3D
@export var material : Material
@onready var mesh := $CSGPolygon3D
@onready var distance = curve.get_baked_length()
# instances
var segments : Array[RigidBody3D]
var joints : Array[PinJoint3D]
var curve_points : Array
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
# store position and rotation
var rotation_buffer = rotation
rotation = Vector3(0,0,0)
var position_buffer = position
position = Vector3(0,0,0)
# Duplicate the curve to ensure its unique and resets properly on reloads, avoiding drift due to re-adding the position_buffer
var cloned_curve = curve.duplicate() # Duplicate curve
curve = cloned_curve # Assign it as the active curve of the Path3D
# CSG Mesh shape array
var myShape : PackedVector2Array
for i in (number_of_segments+1):
curve_points.append(curve.sample_baked((distance*(i))/(number_of_segments), true))
curve.clear_points()
# create cable segments
for i in number_of_segments:
# create rigidbodies
segments.append(RigidBody3D.new())
self.add_child(segments[i])
# position rigidbodies between the joints
segments[i].position = curve_points[i] + (curve_points[i+1] - curve_points[i])/2
# create collision shape 3Ds
segments[i].add_child(CollisionShape3D.new())
# add capsule shape
segments[i].get_child(0).shape = CapsuleShape3D.new()
segments[i].get_child(0).shape.radius = cable_thickness
segments[i].get_child(0).shape.height = (curve_points[i+1]-curve_points[i]).length()
# small offset added to prevent Vector UP
segments[i].look_at_from_position(curve_points[i] + (curve_points[i+1] - curve_points[i])/2 + Vector3(0.001, 0, -0.001), curve_points[i+1])
segments[i].rotation.x += PI/2
segments[i].linear_damp = physics_dampening
segments[i].mass = cable_segment_mass
# create pin joints
# attach joints to rigidbodies path
if i == 0 && fixed_start_point:
#joints.append(ConeTwistJoint3D.new())
joints.append(PinJoint3D.new())
self.add_child(joints[i])
joints[i].position = curve_points[i]
joints[i].set_param(PinJoint3D.PARAM_BIAS, joint_bias_or_stiffness)
joints[i].set_param(PinJoint3D.PARAM_IMPULSE_CLAMP, max_impulse)
else:
#joints.append(ConeTwistJoint3D.new())
joints.append(PinJoint3D.new())
self.add_child(joints[i])
joints[i].position = curve_points[i]
joints[i].node_a = segments[i-1].get_path()
joints[i].node_b = segments[i].get_path()
#add new curve points
curve.add_point(curve_points[i])
curve.add_point(curve_points[number_of_segments])
# setup mesh array
for i in mesh_sides:
myShape.append(Vector2(sin(2*PI*(i+1)/mesh_sides), cos(2*PI*(i+1)/mesh_sides)) * cable_thickness)
# setup mesh
mesh.polygon = myShape
if material != null:
mesh.material = material
# restore position and rotation
rotation = rotation_buffer
# lock joints and segments position and rotation
for segment in segments:
segment.top_level = true
segment.position += position_buffer
for joint in joints:
joint.top_level = true
joint.position += position_buffer
# set rotation and position to 0
# fix start point
rotation = Vector3(0,0,0)
if fixed_start_point:
joints[0].node_b = segments[0].get_path()
if fixed_end_point:
#joints.append(ConeTwistJoint3D.new())
joints.append(PinJoint3D.new())
self.add_child(joints[-1])
joints[-1].position = curve_points[-1] + position_buffer
joints[-1].node_a = segments[number_of_segments - 1].get_path()
# attach rigid bodies if they exist
if rigidbody_attached_to_start != null:
joints[0].node_b = rigidbody_attached_to_start.get_path()
if rigidbody_attached_to_end != null:
if fixed_end_point == false:
joints.append(PinJoint3D.new())
self.add_child(joints[-1])
joints[-1].position = curve_points[-1] + position_buffer
joints[-1].node_a = segments[-1].get_path()
joints[-1].node_b = rigidbody_attached_to_end.get_path()
func _physics_process(_delta: float) -> void:
# update curve positions
for p in (curve.point_count):
if p < (number_of_segments):
# get the first segment and subtract it's basis * distance to point at the endpoint
curve.set_point_position(p, segments[p].position + segments[p].transform.basis.y * segments[p].get_child(0).shape.height/2)
else:
# get the last segment and add it's basis * distance to point at the endpoint
curve.set_point_position(p, segments[p-1].position - segments[p-1].transform.basis.y * segments[p-1].get_child(0).shape.height/2)
@@ -0,0 +1 @@
uid://c5fl7o5ss1q12
@@ -0,0 +1,22 @@
[gd_scene format=3 uid="uid://dwd6ekhtmle0x"]
[ext_resource type="Script" uid="uid://cs7qcnta84qhc" path="res://pinjoint-ropephysics-example/scripts/projectile.gd" id="1_pda7w"]
[ext_resource type="Material" uid="uid://cla83y5h0026e" path="res://addons/pinjoint-ropephysics/materials/light_rope.tres" id="2_vs7vu"]
[sub_resource type="SphereShape3D" id="SphereShape3D_v8hb4"]
radius = 0.2
[sub_resource type="SphereMesh" id="SphereMesh_5yrm1"]
radius = 0.2
height = 0.4
[node name="Projectile" type="RigidBody3D" unique_id=798993199]
mass = 10.0
script = ExtResource("1_pda7w")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1227402127]
shape = SubResource("SphereShape3D_v8hb4")
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=402814720]
material_override = ExtResource("2_vs7vu")
mesh = SubResource("SphereMesh_5yrm1")
Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

@@ -0,0 +1,42 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cm23wh7dgtjxu"
path.s3tc="res://.godot/imported/texture_08.png-cead52bf1956b41f1545e41e2cb1d96c.s3tc.ctex"
path.etc2="res://.godot/imported/texture_08.png-cead52bf1956b41f1545e41e2cb1d96c.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Dark/texture_08.png"
dest_files=["res://.godot/imported/texture_08.png-cead52bf1956b41f1545e41e2cb1d96c.s3tc.ctex", "res://.godot/imported/texture_08.png-cead52bf1956b41f1545e41e2cb1d96c.etc2.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@@ -0,0 +1,42 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://35sytdecvva"
path.s3tc="res://.godot/imported/texture_09.png-a3f28d459e60caea4be06e76f294baf8.s3tc.ctex"
path.etc2="res://.godot/imported/texture_09.png-a3f28d459e60caea4be06e76f294baf8.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Dark/texture_09.png"
dest_files=["res://.godot/imported/texture_09.png-a3f28d459e60caea4be06e76f294baf8.s3tc.ctex", "res://.godot/imported/texture_09.png-a3f28d459e60caea4be06e76f294baf8.etc2.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

@@ -0,0 +1,42 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://crssf8e2w5f38"
path.s3tc="res://.godot/imported/texture_09.png-f8bb94b62e3dc46caee49c835567d427.s3tc.ctex"
path.etc2="res://.godot/imported/texture_09.png-f8bb94b62e3dc46caee49c835567d427.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Green/texture_09.png"
dest_files=["res://.godot/imported/texture_09.png-f8bb94b62e3dc46caee49c835567d427.s3tc.ctex", "res://.godot/imported/texture_09.png-f8bb94b62e3dc46caee49c835567d427.etc2.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

@@ -0,0 +1,42 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bt2p2d2qwh2f2"
path.s3tc="res://.godot/imported/texture_07.png-f2f388a572af5290e8f9d420e5a95821.s3tc.ctex"
path.etc2="res://.godot/imported/texture_07.png-f2f388a572af5290e8f9d420e5a95821.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Light/texture_07.png"
dest_files=["res://.godot/imported/texture_07.png-f2f388a572af5290e8f9d420e5a95821.s3tc.ctex", "res://.godot/imported/texture_07.png-f2f388a572af5290e8f9d420e5a95821.etc2.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

@@ -0,0 +1,42 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cp8kfufswmmmc"
path.s3tc="res://.godot/imported/texture_09.png-ccddf243b48aaae91267489242d5e605.s3tc.ctex"
path.etc2="res://.godot/imported/texture_09.png-ccddf243b48aaae91267489242d5e605.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Orange/texture_09.png"
dest_files=["res://.godot/imported/texture_09.png-ccddf243b48aaae91267489242d5e605.s3tc.ctex", "res://.godot/imported/texture_09.png-ccddf243b48aaae91267489242d5e605.etc2.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

@@ -0,0 +1,42 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://5eqshu0hyxfn"
path.s3tc="res://.godot/imported/texture_09.png-1227078f1331b186930240dd41e9f08b.s3tc.ctex"
path.etc2="res://.godot/imported/texture_09.png-1227078f1331b186930240dd41e9f08b.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Purple/texture_09.png"
dest_files=["res://.godot/imported/texture_09.png-1227078f1331b186930240dd41e9f08b.s3tc.ctex", "res://.godot/imported/texture_09.png-1227078f1331b186930240dd41e9f08b.etc2.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0
Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

@@ -0,0 +1,42 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ccaemffwu4u4r"
path.s3tc="res://.godot/imported/texture_09.png-9fcac0944a1eb9dcc671dfbe995881a3.s3tc.ctex"
path.etc2="res://.godot/imported/texture_09.png-9fcac0944a1eb9dcc671dfbe995881a3.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://addons/pinjoint-ropephysics/textures/kenney_prototype_textures/Red/texture_09.png"
dest_files=["res://.godot/imported/texture_09.png-9fcac0944a1eb9dcc671dfbe995881a3.s3tc.ctex", "res://.godot/imported/texture_09.png-9fcac0944a1eb9dcc671dfbe995881a3.etc2.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0