koyugaki
(コユ゚)
December 14, 2022, 2:13am
#1
I have 3 parts: the blue part (A), red part (B), and the grey part in the background (C)
I want A (the blue part) to have a new position or cframe that has the X cframe of the red part, and the Y and Z of the grey part.
I’ve tried ToWorldSpace()
and VectorToWorldSpace()
, but ultimately I can’t get it to work.
Keep in mind I need them to align in the way I stated above while taking rotation into account.
DataSigh
(DataSigh)
December 14, 2022, 2:47am
#2
Could you show an image of what the result would look like?
koyugaki
(コユ゚)
December 14, 2022, 2:48am
#3
It should look identical if not more accurate in the image above, the blue part should be aligned by the X axis of the red part, and Y,Z should be aligned with the grey part.
koyugaki
(コユ゚)
December 14, 2022, 2:49am
#4
With rotation of the grey part taken into account.
DataSigh
(DataSigh)
December 14, 2022, 2:53am
#5
local greyPart = ...
local bluePart = ...
local redPart = ...
local rx, ry, rz = greyPart.CFrame:ToOrientation()
bluePart.CFrame = CFrame.new(redPart.CFrame.Position.X, greyPart.CFrame.Position.Y, greyPart.CFrame.Position.Z) * CFrame.fromOrientation(rx, ry, rz)
Maybe something like this?
koyugaki
(コユ゚)
December 14, 2022, 2:58am
#6
Nothing happened not even errors, but I’ve already tried using ToOrientation()
When I used it yesterday it did work, but the Z axis wasn’t fully aligned with the grey part.
koyugaki
(コユ゚)
December 14, 2022, 4:06am
#7
Yeah ToOrientation()
probably isn’t going to satisfy my problem, I’ve got so close with just multiplying cframes, but they are never fully aligned…
TenBlocke
(Decablocks)
December 14, 2022, 8:41am
#10
You could just set the CFrame by reading off some position values and adding it to the rotation cframe of the grey part.
local BluePart, RedPart, GreyPart = --Blue, Red, and grey
local RedPos, GreyPos = RedPart.Position, GreyPart.Position
local GoalRot = GreyPart.CFrame.Rotation --Get blank rotation data, no position data
local GoalPos = Vector3.new(RedPos.X, GreyPos.Y, GreyPos.Z) --create a position from your specifications
BluePart.CFrame = GoalRot + GoalPos --add the rotation to the position
koyugaki
(コユ゚)
December 14, 2022, 9:17am
#11
Doesn’t work… Although I’ll take your reply into consideration, honestly I was oblivious to there being a .Rotation
of a CFrame.
koyugaki
(コユ゚)
December 15, 2022, 12:38pm
#14
Solved my own problem.
local GreyPart, RedPart, BluePart = workspace.GreyPart, workspace.RedPart, workspace.BluePart;
local X = -(RedPart.CFrame:ToObjectSpace().X - RedPart.Size.X/2 - GreyPart.CFrame:ToObjectSpace().X);
BluePart.CFrame = GreyPart.CFrame:ToWorldSpace(CFrame.new(X,0,0));
system
(system)
Closed
December 29, 2022, 12:38pm
#15
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.