Third Person Mouse Move Camera Help

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?

  1. What is the issue? I can’t figure out how to get this third person camera effect.

  2. What solutions have you tried so far? I’ve tried to create a custom camera system but everything i tried didn’t work, and i can’t show you code samples because i accidentally deleted them :frowning:

I just need the basics on what to do, like is there already a roblox camera setting that i can just enable/disable, or was i right to just code a custom system?

Any help is much appreciated :pray:

3 Likes

Well if what I think you want to know how to do is make the body move with the camera.

This however is not a basic topic, it is trigonometry values that figure out where the mouse and the camera direction is. Then move the body and face direction to face that way.

To answer question 3 no, there is not a prebuilt roblox camera setting for this it requires custom scripting and alot of patience.

1 Like

A simpler option could be utilizing a BodyGyro, disabling it’s Y force, setting it’s CFrame to where ever the mouse is looking, and at that point you could set the camera mode to Scriptable, and constantly update the camera to be at a set position behind the head or something.

1 Like

Just to be clear, are you asking how to get the charcater to face the direction of the camera in third person? Your question is not very specific.

You could do something like this:

HumanoidRootPart.CFrame = CFrame.new(
	HumanoidRootPart.Position,
	HumanoidRootPart.Position + (Camera.CFrame.LookVector * Vector3.new(1, 0, 1))
)

This will make the HumanoidRootPart face the same direction as the camera, but only on the X and Z axis.

The effect will be instantaneous, so you should research TweenService or cframe interpolation if you want non-instantaneous and more natural rotation.

Edit: In the video, it actually looks like only the waist joint is being manipulated, rather than the position of the entire character. In which case, you can implement something like this (for an R15 character):

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local UpperTorso = character:WaitForChild("UpperTorso")
local WaistJoint = UpperTorso:WaitForChild("Waist")
local WaistC0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)

local Camera = workspace.CurrentCamera

game:GetService("RunService").RenderStepped:Connect(function()
	local angle = math.asin(Camera.CFrame.LookVector.X) * 0.8
	WaistJoint.C0 = WaistC0 * CFrame.fromEulerAnglesXYZ(0, -angle, 0)
end)

You can do similar for the neck joint to rotate the head.
https://developer.roblox.com/en-us/api-reference/class/Motor6D

More reference material about CFrames:
https://developer.roblox.com/en-us/articles/Understanding-CFrame
https://developer.roblox.com/en-us/api-reference/datatype/CFrame

3 Likes

As of 3/4/2020, roblox added a FFlag that disables the camera api. There’s no way to re-enable it (without roblox flipping their FFlag) except by forking it. If you need to use the camera api, and the camera api is still not enabled then you can use this module that re-enables it. It should go into StarterPlayer -> PlayerScripts. It should be noted that you will not receive Camera/Control script updates while using this module.
PlayerModule_PATCHED.rbxm (107.9 KB)

If you’re referring to the mouse locked third person, this can easily be achieved without modifying the camera scripts. I recently had to do this for some guns of mine.

local PlayerMod = require(LocalPlayer:WaitForChild'PlayerScripts':WaitForChild'PlayerModule');
local PlayerCam = PlayerMod:GetCameras().activeCameraController;
if (PlayerCam) then
	PlayerCam:SetIsMouseLocked(true); -- Lock mouse to center
end
-- Makes it so your character does not rotate based on camera, but rather for movement.
UserGameSettings.RotationType = Enum.RotationType.MovementRelative; 


-- You turn this off by setting RotationType to `CameraRelative` and disabling mouse lock.

For future reference, whenever you have issues in the future please clarify on what you mean. There are several things you could be referring to in that video.

8 Likes

Sorry for being really unspecific, what im trying to accomplish is to replicate the system where when you hold down right mouse button it moves the camera, but i need it to do the same thing without holding down the right mouse button. I will try to be more specific on future posts of mine. When i tried to make a whole new custom camera system i locked mouse in center when the mouse delta was changed, i rotate the camera around a sphere whilst pointing at the players head. It didn’t work how i wanted it to so i deleted it and came to the forums for help. Thank you for your comments. @DevConX @C_Sharper @Shardwielder @fireboltofdeath

1 Like

My post above should have answered your question, if it didn’t what issue did you run into or was it not the effect you wanted?

1 Like

This no longer works, the .activeCameraController for the player cam variable keeps returning nil with the new camera module update a couple days ago, i downloaded an old camera module from a year old dev forum post a year ago, i don’t particularly feel safe using it due to the fear of old camera bugs coming back, would you mind helping me find a new fix? i played with it for about 2 hours now with no success. No need to show you my code because it’s almost if not exactly like the one you posted with a few very minor edits, nothing that would effect the outcome.

1 Like

Hey, so this issue cannot actually be fixed unless you fork the camera scripts.
For some very very odd reason, roblox disabled the Camera API entirely.

This is the code responsible for disabling the camera api, it is locked behind an FFlag called “UserRemoveTheCameraApi” which seems to currently be enabled. If you want to re-enable the camera API manually, please replace lines 552-556 with

return cameraModuleObject

image

A follow-up from a staff member regarding why this FFlag exists and why its turned on would be lovely. I don’t see a reason for disabling the camera API.

5 Likes

Could possibly be a mistake they over-looked before releasing the updated camera module, would’t hurt to report it, and thank you once again for your help!

1 Like

Our game broke because of this, it would have been helpfull if Roblox staff responded if this was done on purpose or not, we had to spend a lot of time to figure this out and finally found this thread.

3 Likes

wow, it’s surprising that the camera API has been disabled just like that. That changed the aim system in my game (I was using the API to know if the user is in first person or not). I fortunately had already wrote a backup function that runs instead if it detects something wrong in the API, but it’s a worse function. I still wonder why it was disabled…

2 Likes

i fixed the camera api change by downloading the camera module from 2018 in an old devforum post i found, it fixed it but hopefully i didnt introduce old camera bugs that existed back then. @homermafia1 @KingBr1ck @fireboltofdeath

here is the place you can get the camera scripts from if you still needed it or you need a quick fix.

BaseplateWithNewPlayerScripts_PreRelease3.rbxl (123.9 KB)

1 Like

thank you, but I think I’ll stick with my “worse” function for now, and hope that the API gets enabled back soon, or that, at least, official explanations of this change is given.

2 Likes

Is there any reason you couldn’t use the most recent camera scripts and apply my patch to re-enable the api?
I don’t personally recommend using an older module when you can use a newer one.

EDIT: Here’s the patched version (removes the disable api check as explained above), if anyone wants to use it. It works for me, but feel free to dm me if it doesn’t.

PlayerModule_PATCHED.rbxm (107.9 KB)

3 Likes

can you add this to your solution on this thread to help anyone that might possibly need it? anyway thank you for your help :slight_smile:

2 Likes