Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with CFraming?

Asked by 8 years ago

CLICK FOR PICTURE So in that picture there's a brick with two CFrames colored in blue. What I want to do is CFrame the gray brick so that it attaches between the two green points, therefore making the brick occupy the red area. Problem is, everything I try to get the green points won't work for me, so I came here for help. I already tried Lerping the CFrames but it just goes to the same exact spot every time. ANY help is greatly appreciated. Thanks!

0
What exactly are you trying to do? Your question is a little too vague and/or poorly worded to properly explain your intentions. Are you meaning to make the grey brick at the end align with the red line? User#6546 35 — 8y
0
That is correct. Sorry if the visual/wording is confusing to you, I tried my best. TealTeam 40 — 8y
0
This picture is better: https://gyazo.com/bf331471e0ee6e574f82b7b004ec8a6e BlueTaslem 18071 — 8y
0
As I understand it, the Green is the Red rotated about its Y axis so that it points as vertically as possible (the plane defined by the part's YZ is perpendicular to the floor XZ plane) BlueTaslem 18071 — 8y
0
Correct. This picture is even better. https://gyazo.com/791d3df8134be1c59cf2fe67a9639c28 TealTeam 40 — 8y

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
8 years ago

I believe this will work:

local to = red.CFrame:vectorToObjectSpace( Vector3.new(0, 1, 0) )

green.CFrame = red.CFrame
    * CFrame.new(Vector3.new(), to * Vector3.new(1, 0, 1))

The idea is determining which way is "up" relative to where it was, and then rotate towards that, but only around the Y axis.

0
Words cannot describe how thankful I am for this tiny seemingly worthless piece of code. THANK YOU SO MUCH! You yourself has really helped me, even through past questions I have asked. Thank you so much BlueTaslem. TealTeam 40 — 8y
Ad

Answer this question