How to keep Beam horizontal no matter of the rotation of attachment

Hello, i am currently struggling with keeping the beam same orientation, here is what i mean:

This is my template:

I can clearly see the beams, but i want them to be horizontal like this:

I did that my setting the Orientation of the part to (90,0,0); Starting rotation is (0,0,0)
But for some reason other 2 breaks:
image

I have tried using FaceCamera property but it makes it depend on players camera, but it looks weird:

Ofcourse i could manualy rotate every attachment but it would take a lot of time considering i have 200+ beams.

I have also tried using scripts to fix that but it failed:

Attachment0.CFrame = CFrame.new(Part1.Position, Part2.Position)
Attachment0.Position = Vector3.new(0,0,0)
Attachment1.CFrame = CFrame.new(Part2.Position, Part1.Position)
Attachment1.Position = Vector3.new(0,0,0)

Is there any way to fix it?

if i were you i would make a function that uses 2 parts as arguments and creates 2 attachments with the beam. And then cycle trough all of connected parts

To do what you want, you actually need 2 attachments for each beam, cuz beam curves wrongly if only one rotated right

This is how you can rotate your Attachments to make them face each other horizontally:

Attachment0.WorldCFrame = CFrame.lookAt(Attachment0.WorldPosition, Attachment1.WorldPosition)
Attachment1.WorldCFrame = CFrame.lookAt(Attachment1.WorldPosition, Attachment0.WorldPosition)
Attachment0.WorldOrientation += Vector3.new(0, 0, 90)
Attachment1.WorldOrientation += Vector3.new(0, 0, 270)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.