Search Unity

[RELEASED] Mobile Touch Camera

Discussion in 'Assets and Asset Store' started by BitBenderGames, Sep 2, 2015.

  1. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    375
    im still using the pinch zoom was really nice
     
  2. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    I'm afraid what you are asking for isn't possible using only my asset. The asset is all about enabling the typical CoC likes camera control and not really about orbit-only mode. If anything you might disable the Mobile Touch Camera component to stop the 1 touch drag and then use a custom solution for the orbiting part.
    Either way I will contact you with a private message to talk further about possible solutions for you.
     
  3. AndBje

    AndBje

    Joined:
    Jun 5, 2016
    Posts:
    16
    Hi! I am a very happy user of your excellent Mobile Touch Camera asset. Very nice to be able to concentrate on gameplay and let “experts” handle the camera movements etc..

    In many game scenarios there is a primary object which must always be visible – and your “FocusCameraOnItem” utility script works as a charm. However, there is usually also another object which is also important and often we would like to show it too if possible (considering that the primary object must always be visible and we have boundaries and zoom restraints).

    Something like:
    1. Focus on the main object.
    2. Try to slide the camera so the secondary object is visible (without losing track of the primary object).
    3. If sliding is not enough to show the secondary object, try to zoom out if possible.
    Is it feasible? / Anders
     
  4. AndBje

    AndBje

    Joined:
    Jun 5, 2016
    Posts:
    16
    Hi again! Since I have some UI elements on a canvas I needed to disable the mobile touch camera's events whenever the pointer/touch is over a UI element. I hard-wired it in the Update() function in TouchInputController.cs by adding the following:

    public void Update()
    {
    // If we are over an UI element we ignore the event!
    if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
    return;

    ...


    I am not sure it is the best solution, but it works for me. Preferably this feature should be optional and included in the package (it is always risky to modify an external asset). / Anders
     
  5. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello,

    Would you need this to behave like a one-time camera path? E.g. You have your 2 objects, then the camera does the slide and zoom so both are visible, and then the user is free to pan and zoom around?
     
  6. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    I thought about this issue for quite some time. In order to have some finer grained control I suggest the following method (copy&pasted from the FAQ pages):

    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.

    This also works with images and other UI components. When testing various solutions I found the one you posted to be too general. It may prevent users from clicking through "light-weight" or more or less transparent UI elements.
     
  7. AndBje

    AndBje

    Joined:
    Jun 5, 2016
    Posts:
    16
    Yes, that is exactly what I need, it is just to enable the user to see as much as possible before he/she makes a move.
     
  8. AndBje

    AndBje

    Joined:
    Jun 5, 2016
    Posts:
    16
    Good point. I understand you and it is an easy modification for me (I just have remember it if I update the asset). Happy coding!
     
  9. Grazer2

    Grazer2

    Joined:
    Jun 20, 2011
    Posts:
    86
    Roger. I'll have a look at it within the next few days. Cheers.
     
  10. Circlenumber

    Circlenumber

    Joined:
    Aug 5, 2013
    Posts:
    23
    Can I use tilt camera more degree?Now I test demo,Tilt have little degree.
     
  11. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello. Unfortunately the angle of tilt is restricted. The rule is that the camera must not see above the horizon. This is a mathematical requirement for the pixel-perfect pan and zoom to work. If you need to view your scene from other angles (side-view or from below) you may need another type of camera system.
     
  12. Circlenumber

    Circlenumber

    Joined:
    Aug 5, 2013
    Posts:
    23
    Can I modify someting in C# for more angle of tilt?Other funtion I like,Only angle of tilt I want to change.
     
  13. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    You can modify the angle of tilt directly in the Unity inspector of the Mobile Touch Camera component.
     
  14. Circlenumber

    Circlenumber

    Joined:
    Aug 5, 2013
    Posts:
    23
    How to set camera axes XY? Now my plan is not Z axes.
     
    Last edited: Jan 5, 2018
  15. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Go to the inspector view of the Mobile Touch Camera component (on your camera), and switch the Camera Axes setting to XY_2D_SIDESCROLL.
     
  16. Circlenumber

    Circlenumber

    Joined:
    Aug 5, 2013
    Posts:
    23
    I switch the Camera Axes setting to XY_2D_SIDESCROLL,But in wrong Axes.How to fix?
     
  17. rwherber

    rwherber

    Joined:
    Jan 5, 2018
    Posts:
    5
    have this issue to where anytime I set the max zoom past 15, I get:

    Failed to compute intersection between camera ray and reference plane. Make sure the camera Axes are set up correctly.
    UnityEngine.Debug:LogError(Object)
    BitBenderGames.MobileTouchCamera:GetIntersectionPoint(Ray) (at Assets/Scripts/CameraScripts/MobileTouchCamera.cs:459)
    BitBenderGames.MobileTouchCamera:GetIntersection2d(Ray) (at Assets/Scripts/CameraScripts/MobileTouchCamera.cs:947)
    BitBenderGames.MobileTouchCamera:ComputeCamBoundaries() (at Assets/Scripts/CameraScripts/MobileTouchCamera.cs:892)
    BitBenderGames.MobileTouchCamera:set_CamZoom(Single) (at Assets/Scripts/CameraScripts/MobileTouchCamera.cs:219)
    BitBenderGames.MobileTouchCamera:DoEditorCameraZoom(Single) (at Assets/Scripts/CameraScripts/MobileTouchCamera.cs:1063)
    BitBenderGames.MobileTouchCamera:LateUpdate() (at Assets/Scripts/CameraScripts/MobileTouchCamera.cs:1019)

    However, the axis is set correctly to XZ_TOPDOWN.
    I am attaching 4 screenshots. The first is the camera where the component is. Second is the error when zooming out past 16 (works for anything below 16). Third is screenshot when zoom is less than 16 and forth is zoom past 16 (notice all the blue crap at bottom of the screen).

    Thank you for your help!
     

    Attached Files:

    • 1.JPG
      1.JPG
      File size:
      89.6 KB
      Views:
      779
    • 2.JPG
      2.JPG
      File size:
      54.6 KB
      Views:
      760
    • 3.JPG
      3.JPG
      File size:
      50.8 KB
      Views:
      765
    • 4.JPG
      4.JPG
      File size:
      56.3 KB
      Views:
      659
  18. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    I've already replied to your e-mail but I'll just repaste what I wrote so others may benefit from it when the read it.

    So, this is only partly related to my asset, but the zoom level in your scenario can become too high. In orthographic mode the zoom level modifies the orthographic size of the camera. You can try to tweak that value on the camera directly even in non-play mode and see the blue stuff coming through simply because the bottom area of the camera view frustum is now below the ground level. You can try to move up your camera along the y axis so that with orthographic size 20 (your max zoom value) the bottom area of the camera is just above the ground. You can observe this pretty well in the scene view where you see the camera frustum as 3d rectangular shape and also where the bottom part of that frustum ends. Just set the scene view in the unity editor to orthographic mode, then go into a perfect side-view and you should be able to tweak the camera height perfectly.

    Hope this helps.

    Regards,

    Jürgen
     
  19. rwherber

    rwherber

    Joined:
    Jan 5, 2018
    Posts:
    5
    Thank you!
     
  20. juglarx

    juglarx

    Joined:
    Dec 27, 2014
    Posts:
    60
    @BitBenderGames hi, awesome Asset pack, i dealing with an orbit camera and i cannot make it using your asset do you have any demo/example how to make the camera orbit an object?. Thanks in advance!
     
  21. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello. I'm afraid the asset is not suited for true orbit-mode. It's restricted to work in a plane-like direction instead of being able to do sphere-like motions. If you feel like this isn't what you expected from the asset please send me a private message so we can try to find some kind of solution. Cheers.
     
  22. juglarx

    juglarx

    Joined:
    Dec 27, 2014
    Posts:
    60
    @BitBenderGames thanks!! i´ll try with the solution out of the box to find a workaround... thanks!
     
  23. Atif_Butt

    Atif_Butt

    Joined:
    Sep 22, 2017
    Posts:
    6
    Hey i am having the same problem. how did you solve this one?
     
  24. BrandonYJ

    BrandonYJ

    Joined:
    Jan 5, 2017
    Posts:
    3
    Hi I would like to ask how can I rotate with mouse? cant seems to find the button. Is it possible to change it to right click mouse to move the rotation?
     
  25. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Just a quick and shameless bump to announce that Mobile Touch Camera is now 50% OFF due to being part of the Cyber Week Mega Sale. Grab it while it's hot (and and half the price).

    Cheers,

    Jürgen
     
  26. adaptivemobiledevelopment

    adaptivemobiledevelopment

    Joined:
    Mar 20, 2018
    Posts:
    30
    Hi I see you have a mobile touch pickable. I am trying to move UI items and this script says the object needs a collider. Is there any way to make it work with UI objects? Right now if I move my UI object I just turn off the camera. When I place the item I turn the camera back on but it does a HUGE jump when I do that. Is it possible to ignore my new finger location when I drop my UI item?
     
  27. adaptivemobiledevelopment

    adaptivemobiledevelopment

    Joined:
    Mar 20, 2018
    Posts:
    30
    Also turning the camera off and on works fine on PC it is only on mobile that it appears to move a huge amount after turning the camera back on.
     
  28. adaptivemobiledevelopment

    adaptivemobiledevelopment

    Joined:
    Mar 20, 2018
    Posts:
    30
    Got it. Made the isDraggingSceneObject public. I set it to true before I turned off the camera then to false after I turned the camera back on. Now it doesn't bounce on mobile :)
     
  29. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Now I'm not sure whether to say "sorry for the late reply" or "I'm happy that you managed to figure this out". I guess I'll go for the latter ;-) Have a good day!
     
  30. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Yet another shameless bump to announce that Mobile Touch Camera is again 50% OFF due to being part of the current Tools Sale. Grab it while it's sizzling (and half the price).

    Cheers,

    Jürgen
     
  31. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Hello there, I'm trying to do something really simple but I cannot get it done.
    I would like to simulate a zoom in made by the user on certain point, so, when the game starts my camera is 100 height then I would like to move it down by script until lets say 40... and I would like the tilt to auto trigger obviously. I tried to do it manually by changing the MobileTouchCamera height, zoom, calling autotilt methods but the clipping planes or the tilting always goes crazy. Is there a way to achieve this?
    Thanks
     
  32. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello. So there's a helper script that goes in the direction of what you want to achieve. It's called FocusCameraOnItem. It's included in the asset and you need to attach it to the GameObject that also contains the Mobile Touch Camera. That script has a function

    FocusCameraOnTarget(Vector3 targetPosition, Quaternion targetRotation, float targetZoom)

    You can use that to make the camera move smoothly to the given position, with the given rotation and the given zoom. Are familiar enough with scripting to make this work? Note that tilt doesn't seem to be taken into consideration in that script yet (it's been a long time when I last worked on it). Please feel free to report back if that's something you need added to the script.

    Cheers,

    Jürgen
     
  33. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    I already tried that Script and the problem is, as you said, the camera tilt is not taken into account, which is a huge problem for us, since the tilting is perfectly calculated so we dont rotate the camera to unrendered areas.
    It would be really useful if we could use the tilting with this, im trying to call it manually but it doesn't go as smooth as we like.
    I tried calling manually dozens of methods in the MobileTouchCam script to get it done but the tilting seems attached to the manual input and can't make it by srcript.
    Any help would be appreciated.
    Thanks lot
     
  34. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Gotcha. I just sent you a PM. Let's discuss this in more detail there.
     
  35. tbqoxmf

    tbqoxmf

    Joined:
    Sep 30, 2018
    Posts:
    2
    HI
    your demo scene In Unity Editer
    I can't zoom smoothly
    I input ALT+ Plus or mouse Scroll Zoom is hard

    how can i zoom Unity editer smoothly
     

    Attached Files:

  36. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello,

    This is in fact a feature that is lacking right now since the focus has always been on mobile where the zoom comes naturally from the pinching gesture. Anyway, I will have a look at this and report back to you when I come up with a smooth zoom for the editor/standalone-modes.

    Regards
     
  37. marcjammy

    marcjammy

    Joined:
    Aug 26, 2019
    Posts:
    13
    Please can you tell me how to increase/decrease the sensitivity of the pinch zoom?
     
  38. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello, please go to the Mobile Touch Camera component inspector. There you need to click "Expert Mode Enabled" to reveal some more tweakables and in there you will find the "Custom Zoom Sensitivity" value that you can change from 1 to another value. Cheers
     
  39. artoonie

    artoonie

    Joined:
    Feb 9, 2017
    Posts:
    22
    Hi, is it possible to manually move the camera while using this plugin?

    It seems moving the camera the normal way gets overridden, even when there is no touch input. Perhaps allowing us to call a function which calls `SetTargetPosition` as well as cancels all current in-progress inputs would help - or, updating the camera position based on diffs from the current position instead of the absolute value. Is something like this available, or could it be made available?
     
  40. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello. You can basically just modify the transform.position property of the GameObject which has the Camera component and the Mobile Touch Camera component attached. Could you give more detail how you currently try to move the camera? You could try to disable the Mobile Touch Camera component (.enabled = false) first, but in my tests that's not even necessary. If you want to move the camera to focus a specific object in your scene you can also make use of the FocusCameraOnItem tool-script. You can find some description on how to use that tool inside the script at the top.
     
  41. artoonie

    artoonie

    Joined:
    Feb 9, 2017
    Posts:
    22
    Thank you! I have attempted both of these but neither work unless I disable the mobile touch camera entirely while the camera is in motion.

    I am trying to follow GPS Tracks using the Google Maps API, in which one must regularly call `m_MapsService.MoveFloatingOrigin` in order to move the origin of the entire world, as well as moving the camera through the space.

    Using FocusCameraOnItem works to follow the GPS tracks, but doesn't work when the world origin is moving. It seems it is caching some data outside of its own transform?
     
  42. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    The FocusCamera toolscript is certainly meant to move the camera to a static position. The scenario you describe is more of a follow target kind of behaviour. Also I'm not entirely sure if it's not also another script in your project that may also keep interfering with the camera object's position.

    Can you work with the solution of disabling the MTC component while moving the camera? If not, I would suggest we take this to a private message/conversation to keep finding a solution that works.
     
  43. conan1987

    conan1987

    Joined:
    Apr 8, 2016
    Posts:
    32
    hi
    great asset , but how can rotate the camera around Y axis not Z ? also pickable item doesn't work even that i am attaching a mesh collider and mobile touch pickable script ?
     
  44. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello,

    You may need to change the Camera Axes setting in the inspector from XY_2D_SIDESCROLL to XZ_TOP_DOWN for the rotation. If that doesn't do the trick then I may need some more information about the setup of your scene and what axes you are using for what type of rotation. As for the pickables not working. Could you try pasting your pickables into one of the demo scenes and see if it works there? Note that the MobileTouchPickable script must be on the same Game Object as the collider. Also you should add the Mobile Picking Controller component to one game object in the scene. It's best to put it on the camera which also has the Mobile Touch Camera component attached. Looking forward to hear back.

    Cheers,

    Jürgen
     
  45. conan1987

    conan1987

    Joined:
    Apr 8, 2016
    Posts:
    32
    Sorry for the late reply , I tried to change camera Axis setting to XZ_TopDown but it move the object in Z direction , also i change the refplaneXY in the code to
    refPlaneXY = new Plane(new Vector3(0, 1, 0), groundLevelOffset);
    but the camera rotates around itself not around the object
    here is a screen shot for my scene to show you , i want to rotate and zoom around the 3d object and by the way the pickable are working fine now
     

    Attached Files:

  46. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    So the way I see it you may be looking for an "orbit" style camera control. The bad news is that Mobile Touch Camera is not really suited for this scenario. The asset is instead aimed at games with more or less planar gameworlds. There's no easy way to alter this to fit your needs I'm afraid. I'm willing to get your purchase refunded since the asset doesn't really do what you expected. Please just send me the invoice number via PM if you agree.
    As for your project: You should be able to find orbit or orbit-mode cameras in the assetstore but there should also be tutorials on the web showing you how to write them yourself.
     
  47. conan1987

    conan1987

    Joined:
    Apr 8, 2016
    Posts:
    32
    Thanks for your reply , i am using Mobile touch camera in other projects so there is no need for refund ( I really appreciate your offer ) , and also thanks for the orbit camera advice i will search for it . Thanks again
     
  48. Venzel

    Venzel

    Joined:
    May 7, 2018
    Posts:
    19
    Hi @BitBenderGames!
    Really cool asset! Thank you!

    In order to prevent camera from moving and selecting items while clicking Unity UI you suggest attaching EventTrigger to all buttons, images and so on. It's relevant approach when you just start a project, but when you add Mobile Touch Camera asset to existing project it's not so convenient.

    I've modified your code, now it ignores Unity UI clicking. It's not the best code, I don't know your asset as well as you. Hope it helps you to make Mobile Touch Camera asset even better :)

    1) Add a new method into TouchController.cs
    It works in Editor and mobile (checked on Android). This method let us know if user touch any UI.
    Code (CSharp):
    1. private bool IsFingerTouchGui()
    2.     {
    3.       #if UNITY_EDITOR
    4.       if (Input.GetMouseButtonDown(0))
    5.       {
    6.         if (EventSystem.current.IsPointerOverGameObject())
    7.         {
    8.           return true;
    9.         }
    10.       }
    11.       #else
    12.       foreach (Touch touch in Input.touches)
    13.       {
    14.         if (touch.phase == TouchPhase.Began)
    15.         {
    16.           if (EventSystem.current.IsPointerOverGameObject(touch.fingerId))
    17.           {
    18.             return true;
    19.           }
    20.         }
    21.       }
    22.       #endif
    23.      
    24.       return false;
    25.     }
    2) In the very top of TouchController.Update() replace this code:
    Code (CSharp):
    1. if (TouchWrapper.IsFingerDown == false)
    2.       {
    3.         isInputOnLockedArea = false;
    4.       }
    with this code:
    Code (CSharp):
    1. isInputOnLockedArea = isInputOnLockedArea || IsFingerTouchGui();
    It turns off camera's draging, pinching and clicking on Update() start

    3) In the very end of Update() add:
    Code (CSharp):
    1. if (TouchWrapper.IsFingerDown == false && isInputOnLockedArea)
    2.       {
    3.         isInputOnLockedArea = false;
    4.       }
    It turns on camera's dragging, pinching and clicking on Update() finish for next Update() call if user will up his or her finger
     
  49. BitBenderGames

    BitBenderGames

    Joined:
    Aug 9, 2015
    Posts:
    71
    Hello. Thanks for pointing this out and also for posting a solution. The asset also contains a tool script called "DisableInputOnAllUI" which is supposed to do something similar. I have to admit that this script is a bit hidden by intent since it just blocks all UI elements and that can also be a problem for certain projects. That's why I'm promoting the fine grained solution over this one. Either way, maybe these postings help future readers of this.

    Cheers
     
  50. applicattura

    applicattura

    Joined:
    Mar 28, 2017
    Posts:
    16
    Hello @BitBenderGames I was about to buy the asset but read the UI solution behind the asset.

    Why it doesn't work with the unity UI raycast target bool and You have to make workaround like
    Wouldn't it be an ideal solution to stick with Unity UI raycast target bool and swallow/not swallow touches when it is turned on/off?