Hello there,
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)
cam:WaitForChild("DepthOfField", 1000)
DOF.FarIntensity = 0
DOF.FocusDistance = 0
DOF.InFocusRadius = 0
DOF.NearIntensity = 0
local tween2 = tweenService:Create(
DOF,
TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{
FarIntensity = 0.75,
FocusDistance = 0.05,
InFocusRadius = 10,
NearIntensity = 0.75
}
)
tween2:Play()
print("done") --is being printed everytime, regardless of it working or not.
If you want to test it, you can do that here (simply click the screen): apc - Roblox
Once you clicked you can not get out of the screen anymore (I am working on it, it is early WIP). Simply rejoin and look if the issue is still existing for you.
Thank you in advance. It is my first time working with camera filters, so pls bare with me.
Edit1 and 2: Added variables to the script, forgot to add them (pls less confusion)
Hey there!
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?
tweenService is not a service and is just an unknown global until you write game:GetService("TweenService"):Create() or create a var above the unknown global
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.