Forum rules - please read before posting.

Depth of field effect

Hello, first of all sorry for my english it is translated by google. 

I would like to know what would be the best way to make a change of focus effect on a game camera.

Currently I try to attach a depth of field script on a game camera and switch to another one that would have different focus but apparently this sript only works on the "main camera".

 What would be the best way through the action list to effect this effect of changing focus?

 Thank you in advance if someone to answer

Comments

  • Welcome to the community, @Piranja.

    In an AC scene, the MainCamera is the only one that does any rendering - all the GameCameras are just "reference" points for the MainCamera to take.  Therefore, any effects you want to add to your camera must go on the MainCamera object.  For more on this, see the Manual's "Camera effects" chapter.

    Each GameCamera, however, does provide a "Depth of field" property that you can configure for each - and this will be read by the MainCamera at runtime.  As there are many ways of making use of this value, however, you must rely on a custom script to take it and apply it to your effect script.  This can be read through script with:

    AC.KickStarter.mainCamera.GetFocalDistance ();

    Again, see the Manual chapter for more on this.  The most common way of achieving a Depth Of Field effect nowadays, however, is to rely on Unity's own Post Processing Stack asset.  An integration script for linking this with AC can be found on the AC wiki here: https://adventure-creator.wikia.com/wiki/Post_processing_depth_of_field
  • edited September 2018
    Hello,
    Thanks a lot for the clarifications !

    In fact I can not express myself on my problem. I wanted to create a transition between:




    but a smooth transision which is done very well with the help of switch camera. But apparently I can not because it is the main camera that renders.
    
    If I understood correctly I must make a script that I must call with send message that will slowly modify the value of DEF in the post processing script attached to the main camera?
    
    It's going to be complicated for a first script, so far I've managed to do it all without a line of code thanks to Adventure Creator!
    
    Thank you again for your wonderful work!
  • The MainCamera will "smooth change" its own Focal Distance value as it does any other property (position, FOV, etc) when transitioning between cameras.

    Reading its GetFocalDistance() value during a transition will return a Focal Distance value that is correctly in-between the two GameCameras.

    Using "SendMessage" only triggers a method - it won't read a value to be processed.  To get the focal distance value and store it into your own script, use:

    float focalDistance = AC.KickStarter.mainCamera.GetFlocalDistance ();

    Again, how you use this value will depend on what asset/script you're using to achieve the DOF effect.  See the wiki link I posted above if you're relying on Unity's PostProcessing - it'll handle it all for you.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.