|
Im trying to make a camera effect, and it's not doing the CFrame.Angles part of the code. I need to have the second argument to CFrame.new as well as the CFrame.Angles. Here is the code:
camera.CoordinateFrame = CFrame.new(workspace.Base.Position+Vector3.new(0,35,0),workspace.Base.Position)*CFrame.Angles(0,90,0)
It doesn't rotate the Camera by 90 degrees on the Y-axis though, but does everything else. |
|
|
I believe its because roblox uses radians, not degrees. 90 degree in radians would be math.pi/2.
camera.CoordinateFrame = CFrame.new(workspace.Base.Position+Vector3.new(0,35,0),workspace.Base.Position)*CFrame.Angles(0,math.pi/2,0) |
|
|
Thanks, but it didn't help. It still doesn't rotate 90 degrees, or change the view at all. I want the view to rotate by 90 degrees, and also I have this in a RunService event so that the Camera is stuck on it. |
|
|
Apparently Im not sure then, I haven't worked much with cameras. Though I am almost positive you will need to use radians instead of degrees. |
|
|
Oh ok, thanks. Do you know in general how to rotate the Camera 90 degrees in terms of what it is seeing though, like rotate the Camera in a birds eye view 90 degrees? |
|
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
Is your CameraType set to Scriptable? |
|
|
No, and the reason why is because when I set it to Scriptable the Camera points to a random spot instead of the base I want it to be looking at, and possibly moves too (not sure). |
|
|
*didn't set to Scriptable |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
Setting the camera type to Scriptable makes the camera's CoordinateFrame exactly to the CFrame you set it, angles included. Using the Scriptable type in this case should work. |
|
|
And why does it only work with the Scriptable CameraType? When I change it to Scriptable, it moves to a random spot and doesn't look at the part anymore. Why is that? |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
When you don't use the Scriptable camera type, the camera either relies on its Focus property or its Subject. If you want the camera to look at a part, you can use this template:
YourCamera.CoordinateFrame = CFrame.new(cameraPosition, partPosition)
You should set cameraPosition to be the point you want the camera to be at. |
|
|
Oh ok thanks! Can you tell me why the Camera moves to a random spot and looks at a random spot with the Scriptable CameraType, because that's what's happening to me, either one or both, not sure. |
|
|
Protip:
X degrees = pi * X / 180 radians |
|
|
Thanks, but I've confirmed that radians/degrees aren't the issue. Now my issue is that it changes to a random spot with the Scriptable CameraType :P. |
|
|
workspace.Base.Position+Vector3.new(0,35,0), workspace.Base.Position
You are trying to look straight down, and ROBLOX does not quite know what to do. Instead, what you should do is set the CFrame then rotate it straight down yourself. |
|
|
Im not quite sure what you mean. You mean set the CFrame, and on a different line set the rotation? Like this:
camera.CoordinateFrame = Blah blha blah (w/o CFrame.Angles)
then
camera.CoordinateFrame = camera.CoordinateFrame*CFrame.Angels(0,math.pi/2,0)
I think this is the same as what I had anyways. Is this what you mean though? |
|
|
CFrame.new(workspace.Base.Position+Vector3.new(0,35,0),workspace.Base.Position)*CFrame.Angles(0,90,0)
CFrame.new(workspace.Base.Position+Vector3.new(0, 35, 0)) * CFrame.Angles(0, math.pi/2, 0) * CFrame.Angles(math.pi/2, 0, 0) --Also, add spaces. It makes everything a bit more readable. |
|
|
Im super confused now. I think this is what I already had besides having 2 CFrame.Angles. Im not 100% sure it's the Y-axis that rotates the camera with birds eye view with CFrame.Angles either, this was just a guess, but I would imagine something to happen even if it's the wrong one, but I tried all 3 axis's and none of them seem to change the Camera in any way. |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
Using this:
YourCamera.CoordinateFrame = CFrame.new(cameraPosition, partPosition)
With the camera type set to "Scriptable" should work perfectly when you multiply it by the angles you want. |
|
|
You had it where one vector was directly below another, causing the CFrame to try and point directly downwards (But there are an infinite number of possible CFrames for it to use, so it might get confused) |
|
|
Im confused. So if I tell the code to point the CFrame at the same spot as the Vector Im positioning the CFrame at, it messes up and results pointing/moving to a random direction? I tried the code with both CFrame.Angles and got the same exact result. |
|
blockooJoin Date: 2007-11-08 Post Count: 17202 |
Well, let's stop for a second here. Can you post exactly what you have right now? |
|
|
No, the issue is that in order to point vertically there are an infinite number of possible CFrame values. But never, EVER use CFrame.new(a, a), as that will result in a lot of NaNs. |
|
|
I still have the original code, as I'm unsure what to change to fix it. What specifically should I change from the original code? |
|