I will change my question with more details to make it more clear:
- In the Assets I created Animator Controller and Animation: Named them both FPSController. FPSController is the object I want to animate it's rotation on the Z from 50 to 0:
- Then I opened the Animator window and dragged the Animation into the Animator window:
- Then I opened the Animation window and recorded the clip: The rotation on Z is going from 50 to 0 in 7 seconds. I'm rotating the FPSController on the Z from 50 to 0:
This is the Animation part and this is working fine. The FPSController(player) is starting when the Z rotation value is at 50 and slowly move to 0.
Now The game is start when the whole camera is blurry. For this I'm using Post Processing. Next step was to create a profile of the Post Processing called it CC and this profile I dragged in the Hierarchy to the FPSCamera:
In the FPSCamera I dragged to it a script name Post Processing Behaviour and then dragged to the script in the Inspector the CC profile: This way the Post Processing effects affecting the camera view:
So to make it clear: I'm rotating on the Z the FPSController by animation. And on the FPSCamera I'm using the Post Processing for making effects.
This is how the game start. This is the game view screenshot. The game start when everything is blurry and the FPSController(player) is rotating to the right by 50 degrees:
Now the part of the animation of rotating the FPSController by 50 is working fine. While it's rotating the FPSController I want slowly by the same time in this case 7 seconds to change the blurry effect and make the picture clear once the animation end. The property of the Post Processing CC profile I need to change is the focalLength. By default I start it with the value of 300. And I need in 7 seconds to change it from 300 to 0.
This is the script I ended with so far: The script is attached to the FPSCamera:
public class DOFControl : MonoBehaviour
public PostProcessingProfile postProcProf;
public Animator anim;
private float clipLength;
private void Start()
AnimationClip clips = anim.runtimeAnimatorController.animationClips;
foreach (AnimationClip clip in clips)
clipLength = clip.length;
InvokeRepeating("incrementSpeed", 300, 0.1f);
var dof = postProcProf.depthOfField.settings;
dof.focalLength -= 1f;
postProcProf.depthOfField.settings = dof;
I'm getting the animation clip time length 7 seconds. But the part with the InvokeRepeating is not working. I want to incrementSpeed the focalLength down from 300 to 0 by 7 seconds. Not sure if using InvokeRepeating is the right way at all.