• Register a free account to view all forum content. Click here to create your own account.

camera manipulation issue

Joined
Jun 4, 2018
Messages
240
Ratings
11
Roblox
proclet
The following scopes should be equivalent. But one of them is working, the other is not. Any idea why, pls ?

Working :

Code:
while wait() do   
    local cameraCFrame = CFrame.new(workspace.camPos.Position, target.Position)     -- WORKING
    camera.CFrame = cameraCFrame
end
Not working :


Code:
while wait() do       
    camera.CameraSubject = workspace.camPos                                            -- NOT WORKING :(
    camera.Focus = target.CFrame
end
Post automatically merged:

the variables are :

local camera = workspace.CurrentCamera
local target = workspace.camLookat
 
Joined
Jul 21, 2018
Messages
64
Ratings
15
Roblox
WizardOfHills
I understand the first (working) code. Second is doing something strange. I cannot figure out what it is.

First, it is keeping wait forever loop, then it sets CameraSubject. According to docs Camera is supposed to follow whatever is assigned to CameraSubject (I never verified whether it actually is true). I understand that it is achieved by frequent modification of Camera.Focus. In next line you are overriding Camera.Focus making the previous line null and void.

Second, it assigns to CameraSubject a value workspace.camPos. I am not quite sure what it is but presumably it is position of the camera. If so, camera will follow itself (it will turn toward itself, probably an error or ignore condition).

Third, you set camera.Focus to target.CFrame. Both values are of the same type, but mean something different. target.CFrame is location and orientation of the target itself. Now camera will be placed on top of the target and made to point in direction in which target is facing. If target is a cube it will be its top facet (I think, again I did not check this). Obviously it is not what is needed.

May I suggest an experiment, something simple:

Code:
camera.CameraSubject = target
 
Joined
Jun 4, 2018
Messages
240
Ratings
11
Roblox
proclet
I understand the first (working) code. Second is doing something strange. I cannot figure out what it is.

First, it is keeping wait forever loop, then it sets CameraSubject. According to docs Camera is supposed to follow whatever is assigned to CameraSubject (I never verified whether it actually is true). I understand that it is achieved by frequent modification of Camera.Focus. In next line you are overriding Camera.Focus making the previous line null and void.

Second, it assigns to CameraSubject a value workspace.camPos. I am not quite sure what it is but presumably it is position of the camera. If so, camera will follow itself (it will turn toward itself, probably an error or ignore condition).

Third, you set camera.Focus to target.CFrame. Both values are of the same type, but mean something different. target.CFrame is location and orientation of the target itself. Now camera will be placed on top of the target and made to point in direction in which target is facing. If target is a cube it will be its top facet (I think, again I did not check this). Obviously it is not what is needed.

May I suggest an experiment, something simple:

Code:
camera.CameraSubject = target
CameraFocus and CameraSubject work in tandem, they do not override each other. Simply put, Focus sets the target, where the camera is supposed to "look" and Subject sets the camera position (or to be more precise, the position of the object that the camera is following).

CameraSubject = target would not make any sense, since CameraSubject is the position of the camera.
Post automatically merged:

Simply put, the camera.Focus propery doesn't seem to do anything.
 
Last edited:
Joined
Jul 21, 2018
Messages
64
Ratings
15
Roblox
WizardOfHills
Could you confirm that you had a look at the docs page I linked in my original post?
CameraSubject is not the position of the camera at all. Position is some distance away from the subject. It is automatic and exact behaviour depends on the value in CameraType property of the camera.
 
Joined
Jun 4, 2018
Messages
240
Ratings
11
Roblox
proclet
Quote myself : "or to be more precise, the position of the object that the camera is following". Which is aproximately the same with the camera position, since the following process is instantaneous (supposedly).
Post automatically merged:

Anyway, I found the following code to be working decently :


Code:
camera.CameraSubject = target
camera.CameraType = "Attach"