How can I rotate CFrame orientation in one direction and keep the same position?


there is an attachment (Camerapart) on the front of the drone that gets rotated up and down.

the players camera cframe is set to the attachments cframe on a renderstepped

Drone.CamPart.CFrame = CFrame.fromEulerAnglesXYZ(math.clamp( xrot + math.clamp(-mouseDelta.Y * 0.01 ,-10,10)  , math.rad(-70), math.rad(70)) , yrot, zrot)

this code changes the attachments position to the middle of the model; i’d like the attachment to stay where it was and still change the orientation

let me know if need more details, thanks

Combine the original position with the rotation. An easy method is to add the position to the rotation needed.

Drone.CamPart.CFrame = Drone.CamPart.CFrame.Position + CFrame.fromEulerAnglesXYZ(...)
1 Like

sorry i dont understand cframes good

Drone.CamPart.CFrame = Drone.CamPart.CFrame.Position + CFrame.fromEulerAnglesXYZ(math.clamp( xrot + math.clamp(-mouseDelta.Y * 0.01 ,-10,10)  , math.rad(-70), math.rad(70)) , yrot, zrot)
-
Players.aeroactual.PlayerScripts.DroneController:193: invalid argument #1 (CFrame expected, got Vector3)  -  Client - DroneController:193

im getting this error

		local rot = CFrame.fromEulerAnglesXYZ(math.clamp( xrot + math.clamp(-mouseDelta.Y * 0.01 ,-10,10)  , math.rad(-70), math.rad(70)) , yrot, zrot)

		Drone.CamPart.CFrame = CFrame.new(Drone.CamPart.CFrame.Position) + Vector3.new(rot.X, rot.Y, rot.Z)

i tried this but nothing happens

X, Y, Z of rot are all 0 because it doesn’t have any position.

I got it backwards. You just needed to put the CFrame first in the addition.

Drone.CamPart.CFrame = CFrame.fromEulerAnglesXYZ(...) + Drone.CamPart.CFrame.Position
2 Likes

thank you alot
awdaw3123f

wefrtwf