How to set part CFrame maintaining its rotation

I’m working on an house placement system, I’ve already made the “terrain” props placement, and now I’m dealing with the wall prop placament, basically the “wall props” are the paintings, but I’ve a problem with the CFrame of these:

Basically the problem is that when I aim to the wall the paint not mantain its rotation due to the change of the X and Z axis, and I also need to add half of the size of the paint to keep it outside the wall, but actually I tried a lot of CFrame configurations but none of them worked :frowning:

If I understand you correctly, you’re saying that the rotation resets when the part is moved. If that’s the case, you should adjust the position only when moving the painting and not the CFrame.

1 Like

look this video:
robloxapp-20240805-2338429.wmv (1,0 MB)
I want the paint to mantain its rotation and obviously show the image side

How are you calculating the rotation of the part?

base:PivotTo(
						CFrame.new(Vector3.new(newX, newY, newZ)) *
						CFrame.Angles(math.rad(mouse.Target.Orientation.X), math.rad(mouse.Target.Rotation.Y), math.rad(mouse.Target.Orientation.Z))
						--	mouse.Target.CFrame:Inverse() *
						--	CFrame.Angles(0,math.rad(mouse.Target.Orientation.Y * 2), 0)
						--	CFrame.Angles(0, math.atan2(mouse.Target.CFrame.LookVector.X, mouse.Target.CFrame.LookVector.Z), 0) *
						--	CFrame.Angles(0, math.rad(rotation), 0 )
					)

This is one of the multiple config I tried…

You are making the part the same rotation as the part you’re hovering over

ok so have I to change it in something like: -mouse.Target.Orientation.Y ?

No, that gets the rotation of the object your mouse is pointing at. You would have to rotate it differently.

You can get this with the normal from a raycast. Cast a ray from the camera position in the mouse’s direction and use CFrame.lookAlong() to look along the Normal, which is a direction (look vector).

1 Like

The normal is the direction looking out from a specific point on a surface.

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