Hello. Im trying to make a game that’s a mix between devil may cry and Sekiro. Devil may cry combat is very fast paced and has a lot of vertical movement. Since the default camera always makes sure that the player is in the center of the screen, it might make the camera jitter up and down a lot.
The problem with this is that I don’t want to script an entirely new system. To me it seems like there is a simple solution like maybe creating a new camera subject that follows the players X,Z positions.
So far I have tried to create a new camera Cframe
that always updates to the players X,Z positions, however the camera decides to orient itself to 0,0,0 (I really don’t want to script a set orientation because it will make the camera janky).
Also, the camera needs to be controllable for this to feel good to use.
Sadly, I can’t send anything from my script currently since i’m writing this from my phone.
Can’t you get the camera’s get the cameras z and x CFrame and use CFrame.new, putting the current x CFrame then 0 for Y and the current Z CFrame. You also should put it on runService.heartbeat
local Character = game.Players.LocalPlayer.Character
local RayParams = RaycastParams.new()
RayParams.FilterDescendantsInstances = Character:GetChildren() -- So the raycast doesn't hit any of the players body parts
game:GetService("RunService"):BindToRenderStep("FixCamera", Enum.RenderPriority.Last.Value + 1, function()
local RaycastResult = workspace:Raycast(Character.PrimaryPart.Position, Vector3.new(0,-1,0) * 100, RayParams) -- Use a raycast to find the ground the player is standing on
workspace.CurrentCamera.CFrame = CFrame.new(Vector3.new(
workspace.CurrentCamera.CFrame.Position.X,
RaycastResult.Position.Y + 6, -- "6" is height off the ground in studs, 6 looks natural to me but change it to your liking
workspace.CurrentCamera.CFrame.Position.Z), -- Camera position
Vector3.new(Character.PrimaryPart.Position.X, RaycastResult.Position.Y + 6, Character.PrimaryPart.Position.Z)) -- LookAt
end)
This code finds the floor the player is on using a raycast and keeps the cameras Y axis offset 6 studs up from the floor. Casting a ray every frame can be expensive, so some work is needed on your part to only update the floors position when necessary!
I should have probably been more specific. The camera should only do this when the player is doing an attack where the camera doesn’t need to follow them vertically.
local function CameraSmoothing()
local x,y,z = Camera.CFrame:ToOrientation()
CameraStabilizing.CFrame = CFrame.new(Humrp.CFrame.X, Camera.Focus.Y,Humrp.CFrame.Z)
Camera.CameraSubject = CameraStabilizing
Camera.CFrame = CFrame.fromOrientation(x,y,z)+Camera.CFrame.Position
end
This is my solution. It allows full camera control and works seamlessly whilst most likely being less expensive than raycasting. It is easy to control and can be quickly adapted.
what it does is it has a object as a reference for where the camera should look (CameraStabilizing). This object tracks the players X,Z coordinates and takes the height of where the head was when the move started. Hopefully someone uses this instead of having to struggle.