|
hey guys, im working on a 2d side scroller based on the 2d tutorial. im working with 2d assets and using sprite manager to deal with the animation. I want to use the zoom features that is set up in the tutorial. it sets the camera distance on certain positions, but when I switch the view to orthographic the distance gets replaced with orthographic size... so my question is this. dose anyone know what I should change in the code to get the camera to zoom out in orthographic mode? ive tried to change the camera distance part to orthographic size but it was not it, at least not just that. the reason for using orthographic view is that Im running into trouble with the assets that are in front and in the back, they are jumping around the z axis, it seems to be something unity dose to give a more realistic sense of depth.
(comments are locked)
|
|
The orthographicSize property of your camera actually is the correct value to change in order to zoom in and out when your camera is in orthographic mode. Changing the orthographic size of your camera shouldn't affect anything else in your scene - i.e. it shouldn't cause anything to "jump around on the z axis", it should simple crop or expand your view to show a smaller or larger area. This is very different from actually moving your camera closer or further from your object. You don't need to actually move the camera at all while you're doing this. If this doesn't solve your problem, you might have to describe more clearly the problems that you're having with things "jumping around". thanks for the you comment, ive gotten it to work now but the thing is, its jumping from one "zoom" to the other, is there a way to make it smooth, like when your moving the camera in closer ?
Apr 16 '10 at 11:39 AM
raggi
Make the change in orthographic size more gradual, it doesn't need to be whole numbers. Also you can multiply the change by deltatime to make the zoom relative to real time rather than number of cycles.
Apr 16 '10 at 12:10 PM
spinaljack
One think you could to to implement a smooth orthographic camera size zoom is by using code similar to this: zoomTimePassed += Time.deltaTime; float t = zoomTimePassed / TOTAL_ZOOM_TIME; camera.main.orthograhicSize = Mathf.SmoothStep(initialZoom, newZoom, t); Note that I haven't tested this code, but it should convey the idea of how it could be done. The SmoothStep function will smoothly change the zoom, without any abrupt changes in the speed at which the zoom is changed.
Oct 10 '11 at 10:16 AM
bernardfrancois
(comments are locked)
|
|
i have a problem with zooming in orthografic view: i build my HUD with gameobjects, and if i change dthe orthographic size i get super small/big HUD elements... is there a simple way to scale them together with the O-size? You'll likely have to have your game area and HUD rendered using two separate cameras.
Apr 26 '12 at 06:49 PM
apocriva
(comments are locked)
|
