0 votes

Hello!
I am trying to rotate some objects so that they connect to each other to form a series of pipes, i want to conect (join) them.
pdt: im creating the objects from a 3d coordinates file,each coordinate is the starting point of each pipe.
I'm basically trying to connect points (coordinates) through pipes

i created the objects and
I managed to create the necessary objects for each pair of coordinates and was able to find the necessary distance to connect them (a simple vector difference), the only problem I have is that I can't rotate them correctly, any ideas?
Thanks in advance!!

code of the rotated objects (v = list of coordinates):

``````    var i=0
while i < len(v)-1:
var csgCil = csgTunel.instance()
var vecActual = Vector3(v[i+1]-v[1])
var largo
var ax
var ay
var az

add_child(csgCil)
largo =v[i].distance_to(v[i+1])
csgCil.set_height(largo)
csgCil.get_child(0).set_height(largo+0.1)
print(largo)
csgCil.translate(v[i])
ax = vecActual.angle_to(vx)
ay = vecActual.angle_to(vy)
az = vecActual.angle_to(vz)
print(ax)
print(ay)
print(az)
csgCil.rotate(vy,ay)
#csgCil.rotate(vx,ax)
#csgCil.rotate(vz,az)
i=i+1
``````

in Engine
edited

Your post seems to be incomplete. Probably images are missing?

A simple method to let one object point at another is to use the `looking_at` method of Transform. I.e. assigning the result of `transform.looking_at(othernode.transform.origin, Vector3(0,1,0))` to its transform.
https://docs.godotengine.org/en/stable/classes/class_transform.html#class-transform-method-looking-at

This should work as long as your pipe meshes are oriented along the z-axis.

Thank you!! i posted the images

## 1 Answer

0 votes

Did you try using "look_at" ?

by (283 points)