Positioning Indicators on a Rotating Wall

I have a wall and variables for the CFrame of each end/edge of the wall.
(The balls are where the Edge CFrames are placed)

I want these circles to indicate the position of a blue brick.

I tried using something like CFrame.new(BlueBrickPos.X, TopCirclePos.Y, BlueBrickPos.Z), but the problem is that if the wall changes to other random orientation, the circles end up floating because they are not relative to the blue brick.

Something like this happens

I know this might seem like a simple issue, but I’m not very good with CFrames, I’m not sure what I’m doing anymore tbh. :sob:

Are the edge frames correct no matter what orientation?

Yes

	LeftBoundings = Part.CFrame * CFrame.new(-(Part.Size.X/2), 0, 0)
	RightBoundings = Part.CFrame * CFrame.new((Part.Size.X/2), 0, 0)
	UpBoundings = Part.CFrame * CFrame.new(0, (Part.Size.Y/2), 0)
	DownBoundings = Part.CFrame * CFrame.new(0, -(Part.Size.Y/2), 0)

this is removing the orientation of the cframe.

Try:

local sphere = coloredSphere.CFrame * CFrame.new(BlueBrickPos.X, TopCirclePos.Y, BlueBrickPos.Z)

I’m terrible with anything related to math with CFrame no exception.

However, after a few attempts, I managed to make this attachment relative to the part (it’s placed in workspace.Terrain and WorldCFrame).

This is the code:


local part = script.Parent

local attachment = Instance.new("Attachment")
attachment.Visible = true
attachment.CFrame = CFrame.new()
attachment.Position = Vector3.zero
attachment.Parent = workspace.Terrain

while true do
	attachment.WorldPosition = part.CFrame:PointToWorldSpace(Vector3.yAxis*0.5+Vector3.xAxis*-0.1)
	task.wait()
end

As I expected, the solution was very simple. I made a variable of the difference between the CFrames and added the difference in CFrames to the BlueBrickCFrame, but without passing the X variable, and that was it, lol.

local UpDiference:CFrame =  PartCF:Inverse() * UpBoundingCFrame
local UpCFrame = PartCF * CFrame.new(0, UpDiference.Position.Y, UpDiference.Position.Z) * CFrame.Angles(UpDiference:ToOrientation())

SphereOrWhatever.CFrame = UpCFrame

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