How do I make my part face where my camera is facing???
I tried using
CFrame.new(part.Position,camera.CFrame.LookVector) --I tried Multiplying the lookvector with different numbers but still doesnt work
You can get the camera’s CFrame’s orientation, assuming you already have the camera’s CFrame:
local camOrientation = camCFrame-camCFrame.Position;
You can then apply that orientation to the part:
part.CFrame = CFrame.new(part.Position)*camOrientation;
Part.CFrame = Camera.CFrame or Part.CFrame = CFrame.new(Part.Position,Part.Position+Camera.CFrame.LookVector) if you want the part to be not on the camera
This is now deprecated:
I agree that CFrame.new(pos, lookat) was a lot easier to use. I think it’s stupid that they’ve deprecated something that a lot of people relied on with both complex and basic camera manipulation.
Although I do think that CFrame.fromMatrix can be a lot more powerful and give creators more control over movement and positioning if done correctly.
Happy Memorial Day to everyone! Always remember to honor those who served in the army to defend their own country.
Anyways, I’ve seen that the news of CFrame.new(position, lookAt) (only the one with the Look At) being deprecated has not spread very far. Many people still use this version, which works absolutely fine, but you shouldn’t use deprecated constructors in your code, should you?
The new version is CFrame.fromMatrix() which is a little more complicated than the d…
You should use this:
function lookAt(target, eye)
local forwardVector = (eye - target).Unit
local upVector = Vector3.new(0, 1, 0)
-- You have to remember the right hand rule or google search to get this right
local rightVector = forwardVector:Cross(upVector)
local upVector2 = rightVector:Cross(forwardVector)
return CFrame.fromMatrix(eye, rightVector, upVector2)