Hello fellow developers, I am making a game like mortal kombat (without gore). And I am trying to think of a way to make the camera zoom out when you cant see both characters.
My current code for the camera :
RunService.RenderStepped:Connect(function()
currentCamera.CameraType = Enum.CameraType.Scriptable
currentCamera.CFrame = workspace.CameraPart.CFrame
TweenService:Create(camera,TweenInfo.new(.00001),{Position = Vector3.new(camera.Position.X, camera.Position.Y, fighter1.HumanoidRootPart.Position.Z + (fighter1.HumanoidRootPart.Position - fighter2.HumanoidRootPart.Position).Magnitude/2)}):Play()
end)
Screenshot for my game :

Only the first fighter walks forward and backwards.
1 Like
I think that wouldn’t work mate since you’re manually changing the camera’s cframe every renderstepped and it would just cancel out your tween and your tween seems like its useless even if it doesnt get cancelled out since the time is 0.00001 there would be no animation effect in that better of just changing the position
No I mean the following the fighter works, the thing I want to do is when the fighter gets far from another the camera goes back until we see the fighters again
TweenService:Create(camera,TweenInfo.new(.00001),
{Position = Vector3.new(camera.Position.X, camera.Position.Y, fighter1.HumanoidRootPart.Position + (fighter1.HumanoidRootPart.Position - fighter2.HumanoidRootPart.Position).Magnitude/2), FieldOfView = (fighter1.HumanoidRootPart.Position - fighter2.HumanoidRootPart.Position).Magnitude * 20}):Play()
This will change the field of view.
There is an error : attempt to perform arithmetic (add) on Vector3 and number
I don’t see where that’s coming from.
This is vector3 and I think roblox doesn’t understand how to add + (fighter1.HumanoidRootPart.Position - fighter2.HumanoidRootPart.Position).Magnitude/2)
Never mind I think I fixed it instead of fighter1.HumanoidRootPart.Position I wrote fighter1.HumanoidRootPart.Position.Z