Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Pro Camera 2D - The definitive 2D & 2.5D Unity camera plugin

Discussion in 'Assets and Asset Store' started by luispedrofonseca, Jul 29, 2015.

  1. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @Async0x42 Thanks for the suggestions! I'll try to bring them to the next update after 1.9.0.
     
  2. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    theANMATOR2b likes this.
  3. HallbergIllustration

    HallbergIllustration

    Joined:
    Mar 15, 2015
    Posts:
    7
    Just tried the Pan and Zoom extension, it's fantastic! thanks for making a so nicely plugin! I really like the feel and control of the feature. Has it been implemented in the newest release yet? Could really use it in the game I'm making ;-)
     
    luispedrofonseca likes this.
  4. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @KennethFaigh Glad you liked it! This new extension will be part of the upcoming version 1.9.0. If you want access before it's released on the store please send me your invoice number and I'll send you a beta.
     
  5. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    v1.9.0 was just submitted to the store and contains the following updates:

    • New extension - PanAndZoom! Move and/or zoom the camera with touch (on mobile) or with the mouse (on desktop)
    • Re-enable triggers calculations after their GameObjects have been disabled and enabled again
    • Added a Zoom method to the core
    • Allow TriggerBoundaries to be defined as starting boundaries at run-time
     
    theANMATOR2b and Async0x42 like this.
  6. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @Async0x42 I've analysed your suggestion and here's what I came up with:

    Screenshot 2016-01-22 15.39.42.png

    Instead of tracking the changes of whatever preset is loaded, I simply added Load and Save buttons (replacing the Apply). The other way around would be quite cumbersome to implement and I'm not sure it would be very intuitive.

    Let me know what you think and if this works for you. Cheers!
     
    theANMATOR2b, ikazrima and Async0x42 like this.
  7. Async0x42

    Async0x42

    Joined:
    Mar 3, 2015
    Posts:
    104
    Yeah that works perfectly, thanks!
     
    luispedrofonseca likes this.
  8. O4s

    O4s

    Joined:
    Jan 15, 2014
    Posts:
    8
    Hi Luis,

    As always, ProCamera is a joy to use and a delight looking at the source code.

    We've been trying out the new Pan and Zoom extension for improving our kinetic style vertical menu. We were wondering if there's a easy way of stopping the camera inertia if you lift your finger and tap the screen again on a touch device?

    Also we've used it in conjunction with the elastic boundaries, so the panning eases back when it goes over the boundaries. It's nice but too subtle, we'd like it to pan further over the boundaries. I thought changing the vertical elasticity size would do this but it doesn't seem to have any effect no matter what number we put it.

    Anyhow, these are just nice to have and thought if you did have any out of the box suggestions it would be great for the ProCamera community if they need to implement something similar :)

    Rich
     
  9. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    Hi @rich, glad to see someone already using the new extension! :)

    The camera inertia on the Pan and Zoom extension is dictated by the Follow Smoothness that you define on the core component. One way to achieve what you want, would be to dynamically change it depending on whether the user is touching the screen or not.
    Not sure if that is something that would be useful for everyone but I'll give it some thought.

    Regarding the elastic boundaries, changing the Horizontal/Vertical Elasticity Size should give you the results you want. I'll see if I can find what's going on.
     
  10. O4s

    O4s

    Joined:
    Jan 15, 2014
    Posts:
    8
    Thanks Luis, super quick response as always!

    I'll investigate the Follow Smoothness, I wouldn't have thought of that :) You might be right whether other people will find it useful. I think most people will have a steady speed and inertia that the camera will stop roughly in the right place. We're coming from the angle of people panning quickly and trying to hit a button while the inertia is happening. So more a UX feature than necessity.

    Cool about the elastic boundaries. Might be some quirk with the pan extension used with the elastic boundaries or more likely, we're being dimwits. Yet again, it's very minor.

    Edit: The ability to stop the panning inertia is used in Clash of Clans quite well. You can make it pan really quickly and stop it with a second touch. So still just a nice to have though.
     
    Last edited: Jan 26, 2016
    luispedrofonseca likes this.
  11. O4s

    O4s

    Joined:
    Jan 15, 2014
    Posts:
    8
    We didn't quite get there with Follow Smoothness to stop the pan inertia on a new touch/click but we did achieve it via :

    1. Change CenterPanTargetOnCamera to a public method in ProCamera2DPanAndZoom.cs (line 304)
    2. Call that method from your touch start or initial click event
    3. The pan target will move immediately to the camera position and cancel out the inertia
    Thanks again Luis for making super readable code.
     
    luispedrofonseca likes this.
  12. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @O4s Glad you figured it out. I've installed Clash of Clans and I've seen how their panning works and it does feel great so I'm going to add this feature to the next release (1.9.2).

    [EDIT]

    Actually, instead of just stopping the camera inertia once the user taps down after a drag, I've decided to implement a parameter that allows you to choose how fast to stop. 0 doesn't stop the previous drag (as before), while 1 instantly stops the camera (like Clash of Clans). Below you can find a GIF that shows what a value of 0.8 looks like:

    pan_and_zoom_stop.gif
     
    Last edited: Jan 27, 2016
    johanneskopf likes this.
  13. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @O4s The elastic boundaries are working with the PanAndZoom extension. However, the way they work is that the camera will only go beyond during a frame and then revert back to the "normal" numeric boundaries. This works well in platformers for example, but not so much here. Because you'd have to be dragging the camera really fast for it to go beyond a certain point.

    Any how, I'm planning to revamp the elastic numeric boundaries with something a few users have asked before which is "Soft Numeric Boundaries". What this will do is ease down the camera speed as you approach the numeric boundaries and it will result in much smoother results. As such, please give me some time as I implement this and I'm sure the results will be worth it.
     
  14. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    Hi Luis!

    Replaced my own camera with your implementation today, and nearly everything worked out of the box. But two questions remained:
    How do I stop the current movement of the camera? (I want to stop the current movement of the camera when opening a UGUI menu.)
    And how do I prevent the movement of the camera while doing stuff in an UGUI menu?

    Thanks, John

    PS: Looking forward to get the same touch-movement feeling like Clash and Clans on mobile, really appreciate your ongoing work!
     
    luispedrofonseca likes this.
  15. O4s

    O4s

    Joined:
    Jan 15, 2014
    Posts:
    8
    That's cool about 'Clash of Clans' style stopping and having the ability to tweak the stopping speed. Honestly, ProCamera2D is one of the best products on the asset store.

    Ah I thought I was probably missing the finer details on how the elastic boundaries worked. Even as is with a tiny bit of elastic easing, it's made our menu that more refined. But if you do manage to implement soft boundaries, we look forward to using it.

    Anyhow, we're really happy and thanks for the 'beyond duty' support.

    Rich
     
    luispedrofonseca likes this.
  16. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @john05 To stop the camera all you have to do is:

    Code (CSharp):
    1. ProCamera2D.Instance.enabled = false;
     
  17. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    @luispedrofonseca Thanks for your fast reply!
    This will stop the movement of the camera instantly.
    But what I want is that the camera don't get the commands to move while
    clicking/interacting with UI elements. If clicking outside of them, the camera should work as usual.
    That worked previously for me:
    Code (CSharp):
    1. if (EventSystem.current.IsPointerOverUIObject())
    2. {
    3.   //.. stop movement of camera here
    4.   return;
    5. }
    Thanks again, John
     
  18. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @john05 That code should still work with ProCamera2D. Just use that code I put on my previous reply where your comment is.
     
  19. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    I can't figure this out.. Can someone please let me if this is possible and how to do it?

    i have multiple trigger boundaries set up.. but how can i trigger the boundaries manually?
    ie: current boundary is A, but i want to trigger boundary C..
     
    Last edited: Jan 28, 2016
  20. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @mrm83 Since v1.9.0, TriggerBoundaries has a method called "SetBoundaries" that will set the camera boundaries to that trigger.
    However, please notice that if your camera targets are currently inside another one, the camera will revert back to that one instead.
     
  21. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    @luispedrofonseca Yeah, that works, but with these lines of code I activate/deactivate the camera for every click outside/inside the GUI.
    Can you tell me where to put this code in your plugin, so that the camera itself doesn't get the mouse/touch input?
    I can't figure out where the ProCamera2D gets the mouse input.

    Code (CSharp):
    1. if (EventSystem.current.IsPointerOverUIObject())
    2. {
    3.   return;
    4. }
    5.  
    Thanks for your help,
    John
     
  22. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @john05 Ideally you shouldn't be changing ProCamera2D code, but instead creating your own code on top of it.

    What I recommend in your case (assuming you're using the PanAndZoom extension) is to toggle the AllowPan and AllowZoom variables using to the code you posted before.

    If you really want to dig in, look at the lines 94-101 on the ProCamera2DPanAndZoom.cs file.
     
  23. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    81
    @luispedrofonseca
    ..because then on every update I make I would have to change these lines of code again.. haven't thought about that.
    And yes, I am using your Pan&Zoom Extension, and it's working great so far!
    Using these two booleans (AllowZoom and AllowPan) is a great solution to stop moving the camera while interacting with the UI.

    Thanks for your patience and time!
    John
     
    Last edited: Jan 28, 2016
    luispedrofonseca likes this.
  24. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    Ok I got it to work without recycling the triggers..

    but there is no transition effect with set boundaries..
     
    Last edited: Jan 28, 2016
  25. gifer81

    gifer81

    Joined:
    Nov 16, 2015
    Posts:
    9
    luispedrofonseca likes this.
  26. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @mrm83 I'll make the Transition method public on the next release that will allow you do that. Please contact me with your invoice number and I'll send you a link with the beta.

    @gifer81 Congratulations on your release! It looks great! ;)
     
  27. mografi_joe

    mografi_joe

    Joined:
    Aug 18, 2015
    Posts:
    14
    @luispedrofonseca Thanks for making this awesome camera! I'm trying to figure out how to extend the Influence trigger so that you can limit the maximum amount of the influence the target can have. As of now it's always 100% once you are fully inside a trigger ( fully looking at the influence target and not the original targets ). Would love if there was a way to ALSO set a value between 0 and 1 to effect the maximum amount of camera influence the target has compared to what its currently targeting.

    I've tried messing with a version of your Influence Trigger script. I'm still getting familiar with all this vector math stuff, and I'm not quite clear how apply influence and other things are working. So I'm not sure what I'd modify to create this effect. I've been able to get it to sort of work, but with wonky behavior. Any suggestions on how to go about adding this without messing up the camera?
     
  28. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @mografi_jpruss2001 I'll investigate and see if this is something that I could add without compromising the base functionality.
    In the meantime, please notice that you can add a Transform to the TriggerInfluence that will act as its "Look at" object. This should probably give you enough flexibility to achieve what you're trying to do.
     
  29. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Hey luis - I just wanted to chime in and say - this package looks to have only gotten better since you released it from an outside perspective. When I saw it the first time I wanted it, but I've had to budget for current projects.
    I have at least two projects I'd like to work on this year that will incorporate procamera into it. And with the Playmaker actions it will only be more fluid with my builds.
    Looking forward to getting to the projects so I can work with this (what looks to be) awesome asset.
     
    luispedrofonseca likes this.
  30. joe_ftg

    joe_ftg

    Joined:
    Nov 9, 2015
    Posts:
    50
    @luispedrofonseca I'm using the speed base zoom but I found that when the camera stops and zooms back in it wasn't particularly smooth. It seems to be because the zoom changes the camera position rather than field of view, so even when the camera is not visibly moving, changes in zoom are actually increasing it's velocity again. My fix was to ignore the zoom change from the velocity calculation, but letting you know in case it would affect anyone else.
     
  31. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @joe_ftg When using a perspective camera you can choose what kind of zoom you prefer with the "Zoom With FOV" option: http://www.procamera2d.com/user-guide/#zoom_with_fov

    The thing is that zooming does effectively move the camera position if your targets are not perfectly centered and it does affect the calculated speed. It's not exactly an error, but a by-product of the action. I'm curious to see how you made it ignore the zoom changes. Can you send me a PM with more details?

    [EDIT]

    @joe_ftg Forget what I said above. I just understood what you were saying. I am indeed taking the depth position in consideration when calculating the camera speed which is obviously wrong! Thanks for pointing it out. ;) It will be fixed in the next release.
     
    Last edited: Feb 5, 2016
    Too-Nerd-To-Die likes this.
  32. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    Hi guys,

    Just to let you know that I'm currently working on V2, so the next few weeks (month maybe) you'll see less frequent updates. It will be a big rewrite focusing on code cleanup, extensibility and flexibility for the future. Oh, and hopefully I'll have time for a cool new extension as well. :)

    You can ask why I need to rewrite if everything seems to be working fine, but the truth is that after 6 months of continuous development, with new features pretty much every 3 weeks, made me realize that a few things could be done better or in a cleaner way.

    Don't worry, hopefully the changes won't require you to do much (if anything) on your side and you'll benefit from the performance improvements out-of-the-box.
     
    Last edited: Feb 6, 2016
  33. BAIZOR

    BAIZOR

    Joined:
    Jul 4, 2013
    Posts:
    112
    Hello! I just installed ProCamera2D, nice plugin. It works great!

    But in our project we have a lot of similar scenes, that's why containing camera inside a big prefab with base objects for a scene is very useful for us. So, Camera is nested inside the prefab. At any scene the prefab has different positions, but ProCamera2D always calculate itself position from global zero, it is really pain for us move the main prefab to zero.

    How can I solve it? Thanks!

    upload_2016-2-10_17-40-53.png
     
  34. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @BAIZOR That's a very interesting use case. Please give me some time to see what I can come up with to solve the issue.

    [EDIT]
    I have good and bad news. The good news are that I've fixed it! The bad news are that this fix will only be part of v2 which is coming in a few weeks.
    The reason for this is that the fix requires a few structural changes that are only part of v2. Trying to retro-fit them into the current release (v1.9.2) wouldn't be very straightforward.
    If you really need this fix urgently, I can give you access to the v2 beta once it's more stable.
     
    Last edited: Feb 10, 2016
    Too-Nerd-To-Die likes this.
  35. BAIZOR

    BAIZOR

    Joined:
    Jul 4, 2013
    Posts:
    112
    @luispedrofonseca Thanks for quick answer! I just fixed it. Before we used CameraFollow2D (from standard assets), I looked at the code and found this:
    void Start() {
    transform.parent = null;
    }


    I just created script with name "NoParent" and put it here. Then the script put on the Camera. It works.
    Structure of our prefab is ok, because changing hierarchy in runtime doesn't make some changes in a prefab.

    It can't produce some bug or wrong logic, I guess. What do you think about it?
     
  36. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    That will work perfect! ;) The solution I mentioned would maintain your current, or any other, prefab structure. If that's not necessary on your case, that will do it.

    Any how, the "generic" solution will still be part of v2 since it can be useful in some cases.
     
    theANMATOR2b likes this.
  37. BAIZOR

    BAIZOR

    Joined:
    Jul 4, 2013
    Posts:
    112
    Damn... we have a huge problem with parallax. Camera is nested in a prefab. The prefab moved from zero to some another position, for example Vector3(300, -100, 0).
    Camera has NoParent script on board, it means camera will be root object at position (300, -100, 0), when scene starts.

    So... when scene runs, parallax cameras are far away from the current camera position (300, -100, 0).
    How can I solve it? Thanks!
     
  38. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @BAIZOR Yes, I can see why that happens with the approach you used. The good news is that the more generic solution for parented cameras that comes with v2 will solve that. Like I said before, if this is really urgent for you get in touch and I'll put you on the beta list.
     
  39. BAIZOR

    BAIZOR

    Joined:
    Jul 4, 2013
    Posts:
    112
    Hm... I am not sure about beta, it is dangerous. Thanks for the opportunity anyway :)
    I had fixed the problem by my new script, which updates ProCamera2DParallax.RootPosition to ProCamera2D.transform.position at start.

    But got another problem with parallax.. :(
    At some scenes ProCamera2D can't release our custom logic, that's why I use my own script for calculating camera position and just provide the position to ProCamera2D manually. But at the point parallax doesn't work, I fixed at via adding PreMoveUpdate before MoveCameraInstantlyToPosition and calling PostMoveUpdate after.
    Result is well, but sometimes I can see parallax's blinks(drags), look likes something occurs asynchronously.

    How much time need to wait for that version 2.x ?
     
  40. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @BAIZOR Not sure I understood your use case... The MoveCameraInstantlyToPosition method should only be used on sporadic events and not on an update loop. Can you please share a sample project that replicates your issues?

    The v2 should be released right before GDC San Francisco in March. The beta should start in a few weeks max.
     
  41. ahmed_decoy

    ahmed_decoy

    Joined:
    May 19, 2013
    Posts:
    58
    Hey @luispedrofonseca

    I have a fairly simple but useful enhancement request for 2D Cinematics Component.

    Any chance you can add SendMessage for when the Cinematic has returned to its regular targets? So at the end of "End Duration" period. I added the code myself for now, but I can see it being useful for other folks.

    Thanks! Keep up the good work!
     
  42. KoneJone

    KoneJone

    Joined:
    Nov 10, 2015
    Posts:
    4
    Hi, my pixel art, non-scrolling, mobile game is in the stage I would need to consider resolution scaling for different devices, so I'm oogling difference solutions and ProCamera2D seems to be the most professional solution available. I would only use it to help with the pixel perfectness and maybe camera shakes.

    As I've designed my game around the "iPhone 6" aspect ratio (wide) and would like the game also work on an iPad (4:3), does ProCamera2D do that out of the box? Will the borders of the wide-screen be cropped on an iPad? I've designed my game kinda nonoptimally in that there's also some action in the edges of the screen, and I would like to avoid any cropping.

    Are there ways to mitigate the problem with ProCamera2D?
     
  43. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @BrothaMan Currently the Cinematics extension already has two events for listening when a cinematic starts and ends - "CinematicStarted" and "CinematicEnded". You can subscribe to them and do your logic in there.
    I guess a SendMessage would be easier for most users though. I'll give it some thought. Thanks for the suggestion! ;)

    @KoneJone At the moment, ProCamera2D does not provide any methods to crop or maintain aspect-ratio. What it will do is scale according to the iPad size while maintaining everything pixel-perfect and to the same relative size.
     
  44. KoneJone

    KoneJone

    Joined:
    Nov 10, 2015
    Posts:
    4
    @luispedrofonseca Thanks for the quick reply. Would you consider adding such aspect ratio related features for a future version of ProCamera2D or are they out of scope? I guess basically it would be enough to somehow control the scaling by defining the side of the screen that should define what the max scaling is. (I.e. for a landscape game, scale by shorter edge would be my choice, as I'm fine with the black bars, or if I would want to fill the whole screen by cropping, I'd choose the long edge to scale by.)

    As this is my first Unity project, I'm quite the noob, so my question might be a dumb one. I haven't yet looked into how the resolution scaling / aspect ratio handling is usually done, and was thinking that maybe ProCamera2D could be an easy shortcut I could just buy. ;)
     
  45. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    @KoneJone That is definitely high on my priority list, but unfortunately not for the next release. The question is not dumb at all especially since this pixel-perfect / cropping / scaling subject is a very complicated one.
     
  46. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    789
    luispedrofonseca likes this.
  47. ahmed_decoy

    ahmed_decoy

    Joined:
    May 19, 2013
    Posts:
    58
    Oh okay, didn't realize those events existed. That works perfectly for me. Thanks!
     
  48. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    Hey guys, just to let you know that v2.0 is now feature complete, so now the polishing phase starts. Everything seems to be in line for the GDC release as initially expected.

    Also, as promised, there's a new extension: TransitionsFX! Here's a sneak peek:

    procamera2d_transitions_fx.gif

    All transitions will be fully customisable and I'll try to add as many as possible for initial release. Any how, more will come with time and based on user requests.

    Cheers!
     
    johanneskopf and Too-Nerd-To-Die like this.
  49. Too-Nerd-To-Die

    Too-Nerd-To-Die

    Joined:
    Apr 28, 2014
    Posts:
    44
    as always, excellence!

    If you need some testing, let me know!
     
    luispedrofonseca likes this.
  50. jeffweber

    jeffweber

    Joined:
    Dec 17, 2009
    Posts:
    616
    Looks great!

    Have you made any progress on soft borders?

    Have fun at GDC!