Mobile Touch Camera Support

For question and support regarding BitBenderGames Unity Asset Store Assets, feel free to send us an email or a unity forum post:

bitbendergames@gmail.com

Unity Forum: Mobile Touch Camera Thread

Mobile Touch Camera FAQ

Q: Is There Demo?
A:
Yes. In the official Forum Thread

Q: The camera only moves left or right. What’s wrong?
A: Make sure the Camera Axes on the MobileTouchCamera script is set properly.

Q: The perspective camera gets zoomed in way too far.
A: The default values for the camera zoom are set to work mainly for orthographic cameras. Perspective cameras need different values. Make sure to find fov or distance values that fit for the min and max zoom and set them on the MobileTouchCamera script for the Cam Zoom Min/Max parameters. Note that you can decide between Field Of View based and Translation based zoom for perspective cameras. Field Of View based zoom leaves the camera position untouched when zooming, whereas Translation based zoom moves the camera in and out for zooming.

Q: The camera rotation doesn’t work. What’s wrong?
A: The rotation feature is disabled by default and must be enabled in the MobileTouchCamera component. The option is called Enable Rotation and is found in the Advanced section of the component in the inspector.

Q: How to prevent the camera from moving when pressing on a Unity UI button?
A: Attach the EventTrigger component to the button, set the Event Type to PointerDown and select the OnEventTriggerPointerDown method from the TouchInputController script, attached to the camera, as event receiver.

Q: How to pick and drag scene objects?
A: Make sure the scene object has got either a Collider oder Collider2D component attached. Then attach the MobileTouchPickable script to the gameobject and it should work.

Q: The camera is not pixel perfect. When panning, the scene is drifting.
A: The camera assumes that the scrollable content of your scene (e.g. the ground of your game-world) is located at y = 0 for top-down cameras or at z = 0 for side-scrolling cameras. So you can either move the objects of your game-world to the 0 position, or you can give the offset value to the Ground Level Offset parameter in the MobileTouchCamera component. Example: You are using a Top-Down camera and the ground plane of your strategy game is located at 0/-12/0 (x/y/z). In order to achieve pixel perfect scrolling of the game-world you need to enter the value -12 in the Ground Level Offset parameter.

Q: Picked items get dragged to odd positions, what’s wrong?
A: In case your ground level is not at y = 0 for top-down cameras or at z = 0 for side-scrolling cameras you need to adjust the Ground Level Offset on the MobileTouchCamera to the ground Level.

Q: When using the MobilePickingController with a custom selection event handler I get an exception “ArgumentException: failed to convert parameters”.
A: In the list of event functions make sure to select the “Dynamic Transform Version” of your event handler. The same function may be in the list twice, with only the dynamic version working properly.

Q: Can I disable the camera smoothing?
A: Yes. You can either set the ‘Camera Follow Factor’ value to something extremely high, e.g. 1000, which practically disables the smoothing. Or you can disable it in code by setting the IsSmoothingEnabled property of the Mobile Touch Camera to false.

Q: Can I make the camera automatically focus on a touched/selected item?
A: You can use the FocusCameraOnItem script to do so. Attach this script to the camera. Then use any of the ‘On Pick Item’ events on the MobileTouchCamera component to invoke the according callback in the FocusCameraOnItem component.

Q: I reset the camera rotation from script and now the camera behaves weirdly, what’s wrong?
A: When changing the rotation, some internal script variables related to the boundary computation need to be recomputed. You can do that by invoking the ResetCameraBoundaries() method on the MobileTouchCamera component.

14 thoughts on “Mobile Touch Camera Support

  1. ILKER

    Is the zoom based on FOV or transform.height? And do the camera boundaries automatically update when a larger terrain is chosen. Do you use other objects for collusion detection to limit the camera boundaries?

    Like

    Reply
    1. bitbendergamesbit Post author

      Hey there. For perspective cameras both FOV and the transform position can be used for zooming. This is a tweakable parameter in the asset inspector.

      The camera boundary can be changed at runtime via a custom script. In the forum I posted a helper-script that computes the boundary from a box collider when the game starts: http://forum.unity3d.com/threads/released-mobile-touch-camera.351890/#post-2602779

      It should be easy to modify this script to work with other colliders or to trigger the update whenever you need it.

      The boundary is computed purely mathematically from the values you give. It does not perform a physics-based collision detection.

      Cheers

      Like

      Reply
  2. ilker

    Hi,
    I actually bought the asset “MobileTouchCamera” and it is really perfect!! I had no problem adapting my project according to the asset. Thank You.

    But, I have a little problem, maybe it is implemented already but I don’t know how to do it.
    Is there a simple way to ignore input to objects underneath the UI? I am using NGUI and created some buttons on the bottom of the page. When I click the button to change the building type, it builds the object underneath the UI element. I’d really appreciate if you could help me with this. (By the way, it is mobie… so touch events are being used…)

    Thanks,
    İlker

    Like

    Reply
      1. Rytis

        I have same issue. My project has hundreds of modals and clicking on them also picks and item underneath them

        Like

      2. bitbendergamesbit Post author

        Hello. There is a tool-script that is part of the asset to help you out with this. It’s called DisableInputOnAllUI. Let me quickly paste the documentation for this script:

        Helper class that will block Mobile Touch Camera Input while the pointer is over any UI element that has the RaycastTarget checkbox activated. Using this script may yield to too many false blockings. It’s more precise to mark each necessary UI element as described in the documentation for the asset.
        Usage: Add this to just one active GameObject in your scene. For example to your main camera or to a stand-alone GameObject that’s always activated.

        Hope this will help you.

        Regards,

        Jürgen

        Like

  3. Aaron Delgado

    Hello! I have looked at your asset on the Unity Asset store and I’d say it is incredible. But I have a few questions for you before I consider purchasing it.

    1) I noticed that the videos showcasing the asset uses a 2D environment. Will it work in a 3D environment?

    2) If one wants to use a 3D environment, can the asset be used on the First Player Character?

    3) Are there touch gestures such as double tap gestures, hold touch gestures, etc. in the asset?

    Like

    Reply
    1. bitbendergamesbit Post author

      Hey there. I’m not completely sure if the Mobile Touch Camera asset is what you are looking for. The asset is aimed primarily at creating “City Building” type of games where you have a top-down camera (or side-view if you set up the game using Unity 2D). The most popular example of this type of game would be Clash of Clans. The asset basically allows you to move around the camera, zoom and tilt and so on. The scenes should actually be flat and not have too much of a height difference for it to work properly at this point. If I understand your second question correctly you are asking if this is also suitable for first person (“shooter”) kind of games, right? That’s definitely something I wouldn’t dare say that it should be used for. The camera does detect double tap, as well as long tap when using the integrated scripts for pickable items.

      Cheers

      Like

      Reply
  4. Hovhannes

    Hello. I’m currently working with unity 5.3.5 and the plug in goes into a conflict with that version of unity. In Scene window camera position is affected from mouse scroll like in Game window. We bought the plug-in and it acts good in unity 2017, but even in new project (completely empty project) when i use 5.3.5 version it works wrong.

    Like

    Reply
    1. bitbendergamesbit Post author

      Hi,

      Are you using any special input device? Is the mouse anything special or unusual? Have you tried Factory Resetting the Unity editor using the UI buttons in the top right corner of unity? I will look into this today, but chances are that this is something that’s wrong with unity, and not with the asset. Anyway, I will report back later.

      Regards,

      Jürgen

      Like

      Reply
      1. Hovhannes

        thanks for quick response, i don’t use any custom inputs, but even if there were custom they must not affect the Scene window. however it can be a unity bug i guess.
        But i am having problems with boundaries. Camera goes outside from the bounds. I’m using 3×3 unit bounds and when i comment GetClampToBoundaries() function it goes outside of bounds. When i do not comment function camera is returning to defined position. What can i do for combinig small bound and GetClampToBoundaries() call?

        Like

    2. bitbendergamesbit Post author

      About your latest post: Could you post some more details about the setup of your camera? What’s the translation, rotation, field of view and camera mode (ortho vs perspective). Also what are the settings of the mobile touch camera component? If possible, create 2 screenshots with those details and send them to me via email. You can find the email address at the top of this page. Regards.

      Like

      Reply
  5. Gerard

    Hi Bitbendergamesbit!

    May I know how to move the camera to a certain position?
    I try setting the camera ground offset and camera transform position,
    but it didn’t work.
    Have some sort of function like MoveCameraTo(vector3 position)?
    then it will move the camera to the given position smoothly

    Like

    Reply

Leave a reply to ilker Cancel reply