- Home /
Problem with Orthographic Camera
I'm working on a Tower Defense Game in Unity and I have the main camera set to Orthographic. I've also set up a zoom in function to allow the player to zoom in and out using the scroll wheel. Here's the code:
if (Input.GetAxis("Mouse ScrollWheel")) {
CameraZoom -= Input.GetAxis("Mouse ScrollWheel") * ScrollSpeed;
CameraZoom = Mathf.Clamp(CameraZoom, 0, 15);
}
Camera.main.orthographicSize = Mathf.Lerp(Camera.main.orthographicSize, CameraZoom, 0.25);
It works great, the only problem is for some reason as the size of the camera gets larger the game its slower and slower. As I zoom out in game the Draw Calls, Tris, and Verts dramatically increase. At a scale of about 15 my drawcalls become about 12,000. At a scale of 0 they are 0 and everything in between.
Why is this? There are at most 40 game objects in the scene at once, most of them static with no rigidbodies. Can anyone help?
How many polygons do these objects have? Is your game 2D or 3D - note that ortographic cameras are for 2D & UI only. 40 2D gameobjects could never cause 12k drawcalls
Answer by TommyCarrella · Jun 27, 2014 at 06:08 AM
It's 3D using the orthographic camera at a rotation of 45 degrees on the x and y axis so that that I can see my game in a view similar to a typical isometric scene. Like this :
But anyways, I figured out the problem I had a written a few lines of code to create a small landscape and didn't realize it instantiated it hundreds of times so it was generating FAR MORE objects than I thought but they were all stacked on each other and I didn't realize. All fixed now lol
So I guess if anyone else runs into this problem it's because you just have too many objects in your scene, nothing to do with the scaling.
Thanks for helping anyways IvovdMarel :)