Placing an attachment based on part rotation (using worldcframe/worldposition because of how the placement works)

So I have a rail grind system (taken from somebody, still don’t quite know what is going on in it), that has a part at 0,0,0. This part has an attachment that (after some quick math), is put in the position where that gives the next destination of where the player/AlignPosition should be. With some math (shown here:

local function GetNewPosition(n0,n1,a)
		return (n1.WorldPosition - n0.WorldPosition) * a + n0.WorldPosition
end

AlignPosition.Attachment1.CFrame = (CFrame.new(GetNewPosition(CurrentPart.Node0,CurrentPart.Node1,a)) * CFrame.new(0,4,0)) --* CFrame.new(CurrentPart.CFrame.RightVector, CurrentPart.CFrame.UpVector, CurrentPart.CFrame.LookVector)

it gets the next position of the attachment. However, this doesn’t create the position parallel, and it ultimately puts the attachment 4 studs above the current part, no rotation. Is this because of the 0,0,0 part (the dummy part) having no rotation and it being parented to that, or is it because of how attachments work.

Help would be appreciated.

:warning: This is very wordy so heads up! :warning:

This gets the relative position between n1 and n0.

This multiplys by a which is never defined so we will never know what that is and adds n0 world position.

In result the relative position is the raw position with the added a * n0.WorldPosition which gives us 4 studs.

Now onto the rotation problem, the reason why is that your using WorldPosition which cannot just be added with a rotation like this: CFrame.new(WorldPositionHere) because there is no rotation value. Add a CFrame.Angles with the values you want and you should be fine.

TLDR: Your getting the relative position between 2 attachments added with a * n0.WorldPosition and not including any rotation in your CFrame.

aight thank you very much, i put the cframe.angles before multiplying the value by 0,4,0, now i just gotta get the rotation to tween instead of using alignorientation because of choppiness.

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