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

Resolved Reflections issue when camera moves

Discussion in 'Editor & General Support' started by vfontoura, Jun 29, 2023.

  1. vfontoura

    vfontoura

    Joined:
    Oct 9, 2014
    Posts:
    40
    Hello everyone, how is it going for you all, hope I'm doing this on the correct place now. Well I was following this tutorial over here > How to make a Planar Reflection in Unity URP - Source Code Available - YouTube about planar reflections, but just like the guy on the tutorial I wasn't able to get rid of that annoying delay the camera has when moving and this kinda broke the reflection effect, so If any of you knows the solution for that I'm all ears.

    Thanks and Cheers!
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,833
    The camera which is being used to render to a texture needs to be updated after anything else. If you're using Cinemachine, it calculates the main camera position after most other LateUpdate() methods get called, so you just need to calculate the reflection camera position after that. There are a couple ways to do it: set the Script Execution Order for your script to be a higher number than Cinemachine's (they run at +100 and +200 so you can run at +300 to beat them). Or if you're using a scriptable render pipeline (URP or HDRP), you can respond to the Camera's onPreRender event with your own delegate function.

    https://docs.unity3d.com/ScriptReference/Camera-onPreRender.html
     
  3. vfontoura

    vfontoura

    Joined:
    Oct 9, 2014
    Posts:
    40
    Thx by the insights but I'm using a normal unity camera not Cinemachine, and unfortunately onPreRender do not work anymore for what I've founded. the code of my camera is in Late Update btw
     
  4. vfontoura

    vfontoura

    Joined:
    Oct 9, 2014
    Posts:
    40
    Hey Halley you gave me an insight for a really dumb solution, I've inverted the Updates to Late Updates and vice versa and it worked so Thx you've solved the problem :D