How to make a beam always straight?

Currently, the beam I am using does this when I move an attachment to the side:

Ideally, it would do this instead:

However, I can only achieve that effect with FaceCamera on. This is not ideal, as I’d like the beam to remain flat against the ground at all times. FaceCamera causes this to occur:


So, I’m at a loss. I’m sure there’s some kind of math I could do in scripting to rotate the two attachments. Any help?

1 Like

You could try:

Attachment0.CFrame=CFrame.new(Vector3.new(Attachment0.Position),Vector3.new(Attachment1.Position))
Attachment1.CFrame=CFrame.new(Vector3.new(Attachment1.Position),Vector3.new(Attachment0.Position))

This should point each attachment at the other. You’ll probably have to add on another constant angle so that they actually face the correct direction, but this is a general solution.

1 Like

Thank you, this solution worked perfectly!

For anyone else experiencing a similar problem, this is how my code looked once finished:

A1.WorldCFrame = CFrame.lookAt(A1.WorldPosition, A2.WorldPosition) * CFrame.Angles(0,0, math.rad(-90) )
A2.WorldCFrame = CFrame.lookAt(A2.WorldPosition, A1.WorldPosition) * CFrame.Angles(0,0, math.rad(90) )
1 Like

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