3D cylinder between points

Godot Version

4.2.1

Question

Hello! I want to visually imitate a rope between my first person controller and a static point in 3D space. I’m fine if it’s just a plain cylinder which changes its height and angle when the player moves.

The angle is actually what I’m struggling with, I need a code snippet for it in GDScript. I’m also not sure if its position must be calculated relatively to the player or globally.

You can assume that the cylinder is created as the player scene child node, it’s MeshInstance3D with CylinderMesh child, it’s named as _rope_mesh, and its needs to be updated in player’s _process() function. Sending grace rays upon you all. :pray:

Found a tut. This one is very fast, and in Godot 3, but maybe you can get the idea. https://www.youtube.com/watch?v=0AR7RqQ_QzU

Here’s a plugin for G4 : Rope3D - Godot Asset Library

It’s best to work from something like that and try to understand the ideas.

hth

1 Like

Hello! Thank you for you attention. However, I need a simplier solution, without multiple links or physics. I will leave the topic opened for a while.

I did a small project for you.

1 Like

I appreciate your effort. However, I need a solution with rotation in all 3 axes. Your solution is top-down, only for horizontal plane. I think that the problem can be solved without touching individual vertices. Something like finding a vector pointing from the player to the target point and then rotating the rope mesh along the vector.

My code is fully 3d with a from and to vec3. The only 2d part is the mouse movement stuff.

Another idea is to use a path3d and csg polygons. Draw the path from ↔ to and then sweep the csg path along that.

1 Like

Hey! Thanks for the code, It was exactly what I needed to create a “Grapling Hook” effect for a fps controller. I basically used a raycast collision point as the “to” parameter and the player position as “from”, it worked flawlessly.

1 Like