- Home /
Camera Rendering Skewed Until Transform Adjusted
Greetings.
I have an orthographic camera looking straight down at a scene. The problem is that when you launch the app, the contents it is rendering show up "pulled downward" about 5%, as if the camera's position was about 15 or so units further up the positive Z-axis than it actually is. In addition, it seems to cut off any part of a particular object's mesh that's near the bottom 5% of the frustrum. (The object is in the same layer as other objects that are still rendered down in that area.)
However, if you go to the Inspector during run time and adjust anything in its transform (position, rotation or scale), even properties that don't have any affect on the camera's rendering or frustrum like scale or position.y, the contents snap up and show everything correctly as you'd expect given its orientation. Thus, one could conjecture that the camera is being intialized in some weird state, and that this state is corrected when an adjustment to the transform is made.
This is all I do (of relevance) from its simple script in Awake():
camera.aspect=1;
camera.orthographicSize=320;
transform.position.x=320;
transform.position.z=320;
I tried setting position.y to some value at the end of Start() just to see if it would do the same thing as adjusting it from the Inspector, but it did not.
Also, changing anything in the Camera component (size, view port rect, etc.) or any variables in the attached script during run time doesn't correct the rendering offset, only the transform. For kicks, the camera's settings are:
Clear Flags: Don't Clear (Also tried all the others)
Culling Mask: (3 given layers)
Projection: Orthographic
Size: 320
Clipping Planes: 1 (Near), 1000 (Far)
Depth: 0
Rendering Path: Use Player Settings
Target Texture: (None)
So any ideas as to why it's initiating in an off state, what gets refreshed when you adjust its transform in the Inspector, and how to get it to correct this from the get-go?
I reset the entire transform from the Inspector before launch, and with the code above (with a line for ai$$anonymous$$g the rotation downward for kicks) and it worked. No idea what was up, or how doing that fixed it, since it shouldn't have mattered what random position it was in before the launch, as the code still moved it manually just the same. But it works fine now.
Computers for ya.
Your answer
Follow this Question
Related Questions
How to move the background in unity2d for ios game 0 Answers
Multi-layer character rendering 1 Answer
VideoPlayer component using near plane with LRP 0 Answers
Improving the look of Unique/User Planned Scenes 0 Answers
How to make the Health bar on Enemys head not be in relation to Player(main) Camera? 2 Answers