I’m creating a fighting game, and I have created a basic 2D camera system. However, the camera is stationary; and I’d like for the camera to move with the opponent. Something like this clip:
not mine, from one of @tentergram posts’
However I have no idea how you could tackle this, I was thinking something like
CFrame:Lerp
. How would you advise doing something like the clip provided?My current code:
local player = game:GetService("Players").LocalPlayer
local camera = workspace.CurrentCamera
local runservice = game:GetService("RunService")
local character = player.Character or player.CharacterAdded:Wait()
camera.CameraType = Enum.CameraType.Scriptable
camera.FieldOfView = 47.5
local HRP = character:WaitForChild("HumanoidRootPart")
runservice.RenderStepped:Connect(function()
local characterPos = HRP.Position
camera.CFrame = CFrame.new(characterPos) * CFrame.new(0,0,30)
end)