Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Zoom In in MARS AR Camera

Discussion in 'Unity MARS' started by mandloipsm, Jul 1, 2020.

  1. mandloipsm


    Jun 6, 2020
    Greetings Unity Community,

    I am new to Unity and Unity MARS both.
    Why exactly do I want: Designing Sniper for AR FPS game I am trying to make
    What I did:
    I have been trying to use "Zoom In" feature in AR camera of Unity. I tried using it via FieldOfView() and it seems to be working fine while playing it in Simulation View of Unity(using T & Y) but when I run it on Android it does not work.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    5. public class CameraShift : MonoBehaviour
    7. {
    8.     //This is the field of view that the Camera has
    9.     float m_FieldOfView;
    10.     void Start()
    11.     {
    12.         //Start the Camera field of view at 60
    13.         m_FieldOfView = 60.0f;
    14.     }
    16.     void Update()
    17.     {
    18.         //Update the camera's field of view to be the variable returning from the Slider
    19.         Camera.main.fieldOfView = m_FieldOfView;
    20.         if (Input.GetKeyDown(KeyCode.T))
    21.         { m_FieldOfView = 15.0f; }
    22.         if (Input.GetKeyDown(KeyCode.Y))
    23.         { m_FieldOfView = 60.0f; }
    24.         if (Input.touchCount > 0)
    25.         {
    26.             var touch = Input.GetTouch(0);
    27.             if (touch.position.x < Screen.width / 2)
    28.             {
    29.                     m_FieldOfView = 15.0f;
    30.             }
    32.         }
    34.     }
    35. }
    So, I even tried to start with a different field of view(Changed it in Unity Main camera) but the game started with its regular field of view and not what I changed it to{Though it worked fine in Simulation View}.

    I read few posts about Vuforia's Camera Zoom and most of them mentioned that it is not possible but they were old and they weren't about Unity Mars so posted here.

    Device I am using: Samsung Galaxy M30S(It supports AR as rest of the game I created works fine)
  2. cam415


    Mar 26, 2014
    I would also like to know how to change the field of view in the mars camera. Is this even possible? Haven't had any success in ios builds. Seems to only work in the editor.