I want to make a part part rotate towards the direction the player is looking at. Lets say I have a part that has the same orientation as camera of the player, with slightly different position. I want to make it rotate “relative to itself” if its the right saying. Here I made a a picture of what I had in mind:
local RunService = game:GetService("RunService")
local camera:Camera = workspace.CurrentCamera
local obj:PVInstance = -- your object here...
RunService.PreRender:Connect(function(delta:number):()
obj:PivotTo(camera.CFrame*CFrame.new(10,0,0))--Try messing around with (10,0,0) field
end)
I don’t want the part to just have same rotation as camera, I think I need to give you more context to my problem… I have a script that allows me to drag objects using AlignPosition and AlignOrientation, the AlignOrientation constraint follows the rotation of the camera, but I also want to manually rotate the said part using SHIFT + WASD keys, so its like Camera.CFrame - Camera.CFrame.Position + specified position + CFrame.Angles(… , … , …) or something like that
But just using CFrame.Angles is not enough, I want the part to rotate on its own axis, which I dont know how to do
So, you want a part, that has the orientation of the camera, but is on its own position? Let me know if im wrong.
I made this sample, let me know if this is what you want:
local runService = game:GetService("RunService") :: RunService
local part = workspace.Part :: BasePart -- your part
local camera = workspace.CurrentCamera :: Camera
runService.RenderStepped:Connect(function(dt : number) : RBXScriptSignal
local lookDirection = camera.CFrame.LookVector :: Vector3
local target = part.Position + lookDirection :: Vector3
part.CFrame = CFrame.lookAt(part.Position, target)
end)
This does not need to be littered with buzz words. Putting words like “constructor” and “euler” together doesn’t make sense. It just makes it harder to understand.
Especially when the things you mentioned, don’t even exist.
what is a “euler math constructor”? all math library functions are methods/functions, not constructors. If you really want to get your point across, just use normal understandable words that do not need to be googled to understand.
Also bringing matrix calculations into something simple like this is unnecessary, as this definitely not advanced. Also blaming OP for a thing they don’t even know, is unhelpful.
Just use normal understandable words, thats how people understand.
Well, they aren’t “euler math constructors” either, this term doesn’t even make sense.
They are defined, sure, but I usually like to be explicit so the typechecker doesn’t complain when I code in strict mode, and for the sake of clarity and intent as well.
wow, a simple type annotation, really worth dying for.
Can you actually answer my points rather than reviewing my code? You aren’t really being helpful in this thread, with your “euler math constructors”
Well, if it worked, OP would have put a solution already, its interesting they didn’t.
Then, after OP asks a question on how it works:
You straight up answered with gibberish.
AND THEN, you answer with “matrix calculations” for the simplest problem.
And just link documentation to CFrames, then not explaining what else to do. You just HAVE to bring in matrix calculations to seem “smart” but you are just confusing OP for absolutely no reason.
I didn’t say or assume anything. You right now made things up.
I just linked the post to disprove you falsely accusing me of “aren’t really being helpful”.
You didn’t explain your code, used incorrect and vague terminology, brought unnecessary concepts like matrix mathematics, and linked documentation without explaining anything.
I quoted your own words, Im definitely sure nothing was made up.
I already managed to make part have same orientation as camera, with its own position. I used this:
RunService.RenderStepped:Connect(function()
local direction = mouse.UnitRay.Direction
local difference = (camera.CFrame.Position - player.Character:WaitForChild("Head").Position).Magnitude
local position = Vector3.new(camera.CFrame.Position.X + direction.X * (distance + difference), camera.CFrame.Position.Y + direction.Y * (distance + difference), camera.CFrame.Position.Z + direction.Z * (distance + difference))
local cframe = camera.CFrame - camera.CFrame.Position + position
dragEvent:FireServer(cframe)
end)
I really want to be able to rotate part on axis relative to itself. So If part has some weird orientation relative to world (48, 92, 77) for example, for the part it still is (0, 0, 0) until rotated.
Also, sorry for a late reply, I was quite far away from home.