For some reason the part im trying to rotate wont with cframe.angles
I printed out the 2 values and they are dif so idk anymore.
script.Parent.PrimaryPart.CFrame = game.Workspace.CurrentCamera.CFrame * CFrame.Angles(rot.X,rot.Y,rot.Z)
For some reason the part im trying to rotate wont with cframe.angles
I printed out the 2 values and they are dif so idk anymore.
script.Parent.PrimaryPart.CFrame = game.Workspace.CurrentCamera.CFrame * CFrame.Angles(rot.X,rot.Y,rot.Z)
what is rot
?
rotation the x rotation y rotation and z roation
rot = script.Parent.PrimaryPart.CFrame:Lerp(game.Workspace.CurrentCamera.CFrame, 0.1).Rotation
I know what it stands for, I’m asking what the value of the variable is (what is it assigned to)?
To further understand what you’re doing, what’s your end goal, like, what are you trying to achieve?
to rotate a model with cframe angles smh
I can see that, are you trying to make the CFrames look at each other? I can’t really help if I don’t understand the intention since it doesn’t really make sense to me
Alr so it is to put the model to were the camera is, then Lerp it to give it some sway.
its a viewmodel
Have you tried just multiplying it by rot
?
script.Parent.PrimaryPart.CFrame = game.Workspace.CurrentCamera.CFrame * rot
no to rotate a cframe you need to use cframe angles
A CFrame
includes the rotational values with it (that’s why you can do CFrame.Rotation
). CFrame.Angles
is only used if you strictly have an X, Y, and Z with no existing CFrame. But in this case, you have the rotation:
local identity = workspace.CurrentCamera.CFrame
local newCframe = CFrame.new(0, 20, 5) * identity.Rotation
print(newCframe) --> prints a cframe
CFrame.Angles
returns a CFrame. CFrame.Rotation is already a CFrame
Where exactly is this script located in?
Alright, figure it out on your own
just did, cframe angles was not the problem it was the cframe value itself
I know that the problem was solved, but if someone in the future wants a part to sway near the camera, they can use this code. It goes in character starter scripts, as a local script. (I can only assume that sway means the part should orbit the camera a little bit, though I did not use a lerp to do so.) The swaying part is expected to be called MyPart. I hope I didn’t misinterpret something, sorry if I did.
local RunService = game:GetService("RunService")
local part = workspace.MyPart
local camCFrame = workspace.CurrentCamera.CFrame
local angle = 0
local swayDistance = 0.2
part.CanCollide = false
part.Size = Vector3.new(1,1,1)
RunService.Heartbeat:Connect(function()
angle += 0.3
camCFrame = workspace.CurrentCamera.CFrame
-- sway in front of camera
part.CFrame = CFrame.new(camCFrame:VectorToWorldSpace(Vector3.new(0,0,-5)))*camCFrame*CFrame.new(Vector3.new(math.sin(angle),0,math.cos(angle))*swayDistance)
-- sway at camera (requires inward facing triangles, or a model where the backfaces cannot be seen.)
--part.CFrame = camCFrame*CFrame.new(Vector3.new(math.sin(angle),0,math.cos(angle))*swayDistance)
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.