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

unrotated objects

bad rotated objects

in Engine by (20 points)
edited by

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)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.