Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to support motion blur with teleportation?

Discussion in 'General Graphics' started by IgnisIncendio, Apr 25, 2020.

  1. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    Not sure why I couldn't find this, but how does one prevent motion blur from having a one-frame strong motion blur when we teleport the character? This is for a portal mechanic in my game. On the frame that the player is teleported, I would still like the motion blur for any first-person camera rotation to be active, but not take into account the positional difference due to the teleport.
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi @IgnisIncendio,
    Which render pipeline are you using? HDRP? built-in?
     
  3. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    Hi there! I'm using the built-in pipeline.
     
  4. DomKonecny

    DomKonecny

    Joined:
    Nov 25, 2013
    Posts:
    4
    Hello, old thread but I had the same problem.
    What I did is I set the MotionBlur.active = false, teleported the player and I set it active again the next frame.

    Code (CSharp):
    1.  
    2. public PostProcessProfile profile;
    3. MotionBlur motionBlur;
    4.  
    5. void Start() {  
    6.         profile.TryGetSettings<MotionBlur>(out motionBlur);
    7.     }
    8. public void SetMotionBlurState(bool state)
    9.     {      
    10.         motionBlur.active = state;
    11.     }
    12.  
    13. public void SetMotionBlurStateNextFrame(bool state)
    14.     {
    15.         StartCoroutine(SetMotionBlurStateDelayed(state));
    16.     }
    17.  
    18. IEnumerator SetMotionBlurStateDelayed(bool state)
    19.     {
    20.         yield return null;
    21.         motionBlur.active = state;
    22.     }