Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Obi Fluid 2D - Flipping Camera Horizontal Axis
#1
Greetings! Gran sonrisa


I wanted to implement a "Camera Flip" mode where left is right and right is left etc. but the controls remain the same

Below is what I ended up with. It gets attached to the main camera.

Everything still works and looks fine, except the 2D fluid is now invisible.

Hoping to get some hints on where i'm going wrong.

Thanks!

Code:
//attached to MainCamera

public bool flipHorizontal; //toggle me on/off


void OnPreCull()
   {
       camera.ResetWorldToCameraMatrix();
       camera.ResetProjectionMatrix();
       Vector3 scale = new Vector3(flipHorizontal ? -1 : 1, 1, 1);
       camera.projectionMatrix = camera.projectionMatrix * Matrix4x4.Scale(scale);
   }
   void OnPreRender()
   {
       GL.invertCulling = flipHorizontal;
   }

   void OnPostRender()
   {
       GL.invertCulling = false;
   }
Reply


Messages In This Thread
Obi Fluid 2D - Flipping Camera Horizontal Axis - by docgonzzo - 22-06-2019, 01:55 AM