yesterday I experimented with the new Depth of Field Instance. It is very nice, however I am running in some problems.
Currently, Depth of Field does work in 40% of tries, without any script changes in between.
As I want DoF to be animated (tweened) when an event has been fired, I instance it and put it into the local camera. Afterwards, I set all values to 0 and use TweenService to tween them to default.
It does tween and work, however it sometime does not.
Here is my code (not complete):
--there is other script before it, this is inside a LocalScript in StarterGui.
local tweenService = game:GetService("TweenService")
local cam = workspace.CurrentCamera
local DOF = Instance.new("DepthOfFieldEffect", cam)
DOF.FarIntensity = 0
DOF.FocusDistance = 0
DOF.InFocusRadius = 0
DOF.NearIntensity = 0
local tween2 = tweenService:Create(
TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
FarIntensity = 0.75,
FocusDistance = 0.05,
InFocusRadius = 10,
NearIntensity = 0.75
print("done") --is being printed everytime, regardless of it working or not.
First things that comes into my head is the fact you may be applying the effect on game.Workspace.Camera and not on game.Workspace.CurrentCamera. Are you sure the cam variable stands for game.Workspace.CurrentCamera?
That code should work 100% of the time. Could you elaborate on what you mean by the Camera Tweens but the Depth of Field Effect object doesn’t? If your Camera becomes blurry then the object tween was successful and the code works.
Sure. Before the code snippet, I tween the camera (CurrentCamera) so you have the screen in front of it (as visible in test game). Afterwards, the code snippet runs. It always logs “done” in Client Console.