News: Enjoy our Christmas offer 30% off on our latest package Tower Defense Level Kit http://u3d.as/m7h

  • August 18, 2018, 04:41:58 AM

Login with username, password and session length

Author Topic: How to Zoom Camera Field Of View in and out (FIXED) - Now Pan & Tilt freeze on Z  (Read 310 times)

Offline TouchWiz

  • Newbie
  • *
  • Posts: 3
How to Zoom Camera Field Of View in and out with Pinch in and out?

Hey all. I have not used this Unity asset in quite some time. I was wondering how I would zoom-in and zoom-out on the MainCamera in a Scene using Field Of View and this package.

Any ideas? Any code laying round you could share?

I am trying to make the zoom-in and zoom-out on pinch in and out as smooth as possible as well.

Thanks for any insights you all have for me.
« Last Edit: January 15, 2018, 09:18:24 PM by TouchWiz »

Offline TouchWiz

  • Newbie
  • *
  • Posts: 3
Re: How to Zoom Camera Field Of View in and out with Pinch in and out?
« Reply #1 on: January 15, 2018, 08:50:15 PM »
Also, how can we clamp z-axis on the Camera? I do not want that to rotate. It throws the view way off and will confuse some customers. They will not be able to fix the view.

Any ideas? Anyone?

Unfortunate I have not seen a response to my first question yet.

Offline TouchWiz

  • Newbie
  • *
  • Posts: 3
Re: How to Zoom Camera Field Of View in and out with Pinch in and out?
« Reply #2 on: January 15, 2018, 09:16:58 PM »
Related to pan and tilt of the Main Camera.

I did some experimenting with putting some code in this company's ETCTouchPad.cs file.

So far I have the following. It's a bit choppy. I'll have to see what I can come up with to smooth it down more.

// Keeps the Main Camera from rotating at odd angles on the z-axis
       
Code: [Select]
Camera.main.transform.localEulerAngles = new Vector3(Camera.main.transform.localEulerAngles.x, Camera.main.transform.localEulerAngles.y, 0f);
I fist tried this in the OnDrag() method. Really jumping.

Now I am experimenting with it at the bottom of the UpdateTouchPad() method in the same class.

Any suggestions you all have would be appreciated if you have run into this need before. Otherwise I hopes this helps someone else.

Thank you.

Ps. Developer(s). It would be nice to have individual x,y,z axis clamping ability (plus the other clamp option is not working for me. I remember it use too).
« Last Edit: January 15, 2018, 09:22:28 PM by TouchWiz »