Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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:
    860
    @zapposh @TanselAltinel Just to let you know that I've finally found the root of the problem you reported and will be fixed on the next update (2.5.5).
     
    TanselAltinel likes this.
  2. TanselAltinel

    TanselAltinel

    Joined:
    Jan 7, 2015
    Posts:
    155
    So, there actually was an issue? My local builds worked fine, but remote builds and other builds people took were having this issue. I created a work around so it is no longer relevant, but nice to know!
     
  3. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @TanselAltinel There was - on the BasePC2D class. Which explains why the error could occur on any extension. It only happened very rarely because it was dependent on a specific script execution order (which is randomised). Any how, it's fixed now so thanks for the help. ;)
     
  4. zapposh

    zapposh

    Joined:
    Nov 12, 2016
    Posts:
    111
    @luispedrofonseca Excellent, thanks. So I can update to 2.5.5 without issues?
     
  5. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
  6. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    22
    [Request]
    Might be a stupid one, but at least I asked :D Here we go:

    Could you add so that we can turn the "camera window boundaries" into Edge Colliders? It's good for a lot of type of games. For example platformers where you can't backtrack (Super Mario) or whenever you want to keep colliders from bouncing out of the camera boundaries. It's also good for moments when we want to keep the player from leaving a specific area (e.g during dialogs, or moments etc).

    I know this can be done by setting up our own colliders, or freeze the player during moments (how boring), or tons of other solutions... But then every player has a different screen size, and resolution, and sometimes the Pro Camera 2D changes boundaries (when entering a room e.t.c), and a lot of other troubles occur. It would be so much easier with an auto resizing Edge Collider (if even possible)

    Please let me know if this already is in Pro Camera 2D, I tried to similar solutions.
     
    Last edited: Jan 11, 2018
  7. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @BACALL That is definitely possible, but I think it's a perfect fit for a custom extension and not something I think it'd benefit many other users. It's a very specific use-case and Edge Colliders only work on the XY axis, while ProCamera2D works on any axis.
    My recommendation is to have a look at creating your own custom extension: http://www.procamera2d.com/user-guide/custom-extensions-triggers/
    If you have some trouble, join the forum and I'll be glad to help you out. I recommend doing it on ProCamera2D's own forum because it's easier for me to track.
    Cheers!
     
  8. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    22
    Okay, thank you! I joined the forums. For anyone else interested in the topic: http://procamera2d.proboards.com/thread/83/camera-boundary-collision-2d
     
    luispedrofonseca likes this.
  9. luigi7

    luigi7

    Joined:
    Jun 30, 2015
    Posts:
    66
    @luispedrofonseca I ended up using OnUpdateScreenSizeFinished and fitted flawlessly, thankyou ;)
     
    luispedrofonseca likes this.
  10. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    Just submitted the latest version (2.6.0) to the store that adds support for the latest Unity 2018.1 beta and adds some simple integration for the Unity Timeline.
     
    Zehru and tosiabunio like this.
  11. Zehru

    Zehru

    Joined:
    Jun 19, 2015
    Posts:
    84
    very nice :) I hope you can keep going with this amazing asset!
    It's worth buying and its 2D capabilities are beyond expectations! :)
     
    luispedrofonseca likes this.
  12. Rabagast

    Rabagast

    Joined:
    Jan 30, 2013
    Posts:
    78
    Hi!

    I really love ProCamera2D, but I have a question. Is it possible to make the camera follow the player only one direction? For example, if I jump upwards, the camera will follow, but if the player falls down, the camera doesn't follow. If it's not possible, is it possible to add this feature in a future release?
     
  13. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @Rabagast You can achieve that using the NumericBoundaries extension. Simply set the bottom limit of the camera and you should get what you're looking for.
     
  14. Rabagast

    Rabagast

    Joined:
    Jan 30, 2013
    Posts:
    78
    Hi!

    I was thinking I could use that. But then I need to change the bottom limit the higher the player will be. I use Playmaker, so I was thinking I could move the bottom limit up while the player is getting higher or something.
     
  15. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @Rabagast There are multiple ways to achieve this. You could, for example, create an empty object that follows your player only if the current player position is higher than the previous. Add that empty object as the camera target instead of the player.
     
  16. Rabagast

    Rabagast

    Joined:
    Jan 30, 2013
    Posts:
    78
    Ok. But it would anyway be nice if you could lock an axis. For example, lock bottom, so the camera doesn't follow the player down. Only up, left and right.

    It's just a suggestion. :)
     
  17. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @Rabagast Thanks for the suggestion. I appreciate it. Unfortunately it's a bit too specific and I try to keep the plugin as lean and simple as possible by only including more general-purpose features.

    P.S.: At the moment you can disable an axis (horizontal or vertical). Not sure if that suits you though.
     
  18. Rabagast

    Rabagast

    Joined:
    Jan 30, 2013
    Posts:
    78
    I need to lock vertical, but only down (-Y). If I lock vertical, the camera doesn't move either up or down. I can't lock only one direction.

    Anyway, I love ProCamera2D! :)
     
    luispedrofonseca likes this.
  19. mm1982

    mm1982

    Joined:
    Apr 28, 2015
    Posts:
    30
    Hi,

    I just upgraded to make use of the new Content Fitter extension. I am also using the Rooms extension... Im guessing these are not compatible? Im using the Aspect Ratio setting for the Content Fitter... can I still achieve the same Rooms functionality with ContentFitter? The transitions are at least initially messed up for me.

    Thanks for the great work on this asset
     
  20. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @mm1982 It should be working. I'll see what's going on and get back to you as soon as possible.
     
  21. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @mm1982 Just to let you know that I'm still working on a fix for the issue you're getting.
     
  22. mm1982

    mm1982

    Joined:
    Apr 28, 2015
    Posts:
    30
    Thanks, for the update, I appreciate it and the constant improvement you are making to this asset.
     
    luispedrofonseca likes this.
  23. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @mm1982 I've been looking at the issue you reported, and unfortunately it's one of those that I can't circumvent. When using the ContentFitter extension the camera size is forced to a specific size/aspect ratio. If used together with another extension that also tries to resize the camera, it will cause some interference. That's the case with the Rooms extension when the "Zoom" or "Scale To Fit" options are enabled on a room.

    The solution in this case is to not use those options if you have the ContentFitter extension enabled.
     
  24. daklab

    daklab

    Joined:
    Nov 24, 2013
    Posts:
    20
    @luispedrofonseca I am using the PanAndZoom Extension with ProCamera2D 2.6.0 and I've looked at the source code where I didn't see what I was looking for.

    What I am after is this:

    1. An event or approach for being notified when panning starts and ends. Is there a better approach than polling in the `Update()` method against `IsPanning` of a `ProCamera2DPanAndZoom` instance?
    2. When panning I remove all targets via my aforementioned polling approach (to mitigate issues that seem to compete with the Numeric Boundaries extension), but I also want to manually zoom out. Subsequently, on some condition I want to manually zoom in. I may be missing something obvious, but how can I manually zoom in or out if the only target is the auto generated `PC2DPanTarget`?
     
  25. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @daklab

    1) There are currently no events for panning start and end. The solution you have is correct but I'll add those events to the next release.

    2) Not sure I understood what you're trying to do, but you can manually zoom using the "Zoom" method on the core ProCamera2D class.
     
  26. daklab

    daklab

    Joined:
    Nov 24, 2013
    Posts:
    20
    Thank you. Regarding #2, ridiculous oversight on my end though it seems to compete with other extensions (which I'll try to work through).
     
    luispedrofonseca likes this.
  27. mm1982

    mm1982

    Joined:
    Apr 28, 2015
    Posts:
    30
    Hi, thanks for the reply.

    I am not actually using "Scale To Fit" or "Zoom". I guess I am still confused as to what settings are compatible. Can you provide a sample set of Content Fitter settings and a room that are compatible together? I understand if there is no compatibility between these two extensions, but before I start to implement my own solution, I figured I would see what works out of the box first.

    For example, here is my Content Fitter settings


    And this is a sample room Im having trouble with


    Thanks for the help
     
  28. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    891
    Could you add the possibility to stop only certain type of shakes by passing their scriptable objects as arguments? Right now stopping shakes stops all kinds of shakes / constant shakes.
     
  29. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @mm1982 You're getting that issue because you're trying to fit the camera inside a room that is too small for the current settings you have on the ContentFitter.
     
  30. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @FeastSC2 I'll have a look at that and see what I can do. I'll keep you posted.
     
  31. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @FeastSC2 It's not possible with the current architecture of the Shake extension to stop a shake individually, because the shake effects are cumulative (for example, if a gun shot happens while an explosion is occurring, both shakes are added).

    However, you can stop "constant shakes" and "normal shakes" separately by using the "StopConstantShaking" and "StopShaking" methods accordingly.
     
  32. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @luispedrofonseca

    I'm getting an odd problem where I'm unable to add any presets to Constant Shake Presets. They simply disappear when I enter Play mode, and don't return. Regular shake presets work fine. Occasionally when exiting playmode, I'll get an OutOfRange error from PC2D. Any ideas? Currently running 2017.1.2p2 for this project, and PC2D 2.5.2.
     
  33. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @Kirbychwan Yeah, that sounds odd. Do you also get that behaviour with the included demo scene? Also have you tried to upgrade to the latest PC2D version? I don't think I've done any changes on that extension since 2.5.2, but it's always a good idea to upgrade.
     
  34. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    I just updated and get the same behavior; but I believe I know what causes the issue.

    My camera prefab must have the presets set in the Shake script; if I don't apply them to the actual prefab, they disappear in play mode. So in this case, I was trying to implement a constant shake that only occurs in one scene (using the Enable on Start in that specific scene) but since it isn't set as such on the prefab, it doesn't execute it.
     
    Last edited: Apr 22, 2018
  35. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @Kirbychwan I'll have a look at that and get back to you as soon as possible.
     
    Kirbychwan likes this.
  36. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
  37. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @Kirbychwan Here's an example of adding a shake preset at runtime. Just tested it and it works as expected. Is something like this that you're doing?
    Code (csharp):
    1.  
    2. public class RuntimeShake : MonoBehaviour
    3. {
    4.     public ShakePreset ShakePreset;
    5.  
    6.     void Start()
    7.     {
    8.         ProCamera2DShake.Instance.ShakePresets.Add(ShakePreset);
    9.     }
    10.  
    11.     void Update()
    12.     {
    13.         if (Input.GetKeyDown(KeyCode.S))
    14.         {
    15.             ProCamera2DShake.Instance.Shake(ShakePreset.name);
    16.         }
    17.     }
    18. }
    19.  
     
  38. Gemfruit

    Gemfruit

    Joined:
    Sep 15, 2013
    Posts:
    10
    Just wanted to say that I just bought this, and while I've only read the docs quickly, and played with the demo, this seems like a masterful addition to my workflow. It appears to do everything I can think I'd ever need it to, and if I find any edge cases, I'll be sure to bring them up. Thanks a lot for creating a very solid, crucial tool - looking forward to checking back in later after some use.
     
    luispedrofonseca and tosiabunio like this.
  39. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    Thanks @Gemfruit!

    Glad you’re happy with your purchase! Let me know if there’s something I can help with.
     
  40. kapopixel

    kapopixel

    Joined:
    Apr 2, 2017
    Posts:
    47
    Hey @luispedrofonseca,

    You must be hearing this a lot but congrats on this great asset ! If you don't mind, I have just a small question though.
    Is there a way to make the camera pan along a specific line ? I tried to use "rails" and "pan and zoom" together but it seems they are not meant to work together. Rails need an object to follow.
     
  41. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @kapopixel Sure, there are multiple ways of achieving that. The simplest one is to create the path you'd like using the Rails extension. Then add an empty GameObject as the camera target and make it move automatically on either direction.
     
    kapopixel likes this.
  42. kapopixel

    kapopixel

    Joined:
    Apr 2, 2017
    Posts:
    47
    @luispedrofonseca thanks, but let me clarify my question please. When I use "Pan and Zoom" extension, I can configure it in a way that it only allows horizontal panning along the x axis. So, what I am asking is, if Pro Camera 2D is capable of creating a specific line (let's say half pentagon) that only allows panning along this line instead of panning along x axis and y axis.

    I understand your solution but in this case I have to write a script that moves the empty GameObject by holding and dragging the mouse (or moves the GameObject by swipe gesture in mobile platform)

    Thank you !
     
  43. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @kapopixel Yes, in that case you'll have to write a script to move the GameObject according to your specifications.
     
  44. mercuron

    mercuron

    Joined:
    May 11, 2015
    Posts:
    2
    Thanks for this really nice plugin. I would like to use it for my project but need to know if it somehow supports an "asymmetric view frustum". I am using a perspective projection but want to shift the vanishing point of the perspective away from the center of the screen. There is a solution for this in the second example of https://docs.unity3d.com/ScriptReference/Camera-projectionMatrix.html and I could use this code, of course.
    I could not find this feature in your examples. Did I miss something? If not, would you see any potential issues when I am going to mess with the camera's perspective matrix?

    Thanks a lot!
     
  45. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @mercuron I'm not familiar with the concept of asymmetric view frustum but I'll look into it and get back to you.
     
  46. Rocktavious

    Rocktavious

    Joined:
    May 10, 2017
    Posts:
    44
    hey @luispedrofonseca - really awesome asset you got here - really great and easy to work with so far. I do have 1 question about the pan & zoom functionality. I'm trying to figure out how to have pan work both when your mouse is at the edge of the screen OR if you click and drag OR if you use keyboard input such as WASD - the first two i can get working but i've tried a few different things to get "keyboard" control working to no avail. Do you have any examples or ideas on how to properly achieve this? I'm trying to make a TopDown camera feel like that of an RTS type game.
     
  47. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    @Rocktavious For the keyboard control you'll have to write a custom extension or make changes to the PanAndZoom extension. The simplest way is to "manually" move the GameObject (PC2DPanTarget) that the PanAndZoom extension creates and uses to move the camera.
     
  48. BrothaMan

    BrothaMan

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

    We're currently brainstorming a few ideas to improve performance in our game. One of our biggest hits we take is the CPU rendering time in our parallax cameras. ProCamera2D is deeply integrated into our game at this point so we're thinking of solutions of improving performance while mostly sticking with the current set up in our scenes.

    So basically we have 6 Parallax cameras being used in our Pro Camera 2D Parallax. We realize the performance isn't really anything in the ProCamera2D code itself, its just that with every new parallax camera, takes a good hit on performance. This post is more to pick your brain a bit on parallax methods in general.

    If we render everything in only 2 cameras performance jumps significantly (~30% increase). So one possibly obvious solution is we just need to cut back on parallax cameras and go with fewer layers. I'm gonna leave that one for a last resort since we like the depth our 6 layers provide. So that brings up thinking of other methods of achieving parallax.

    I saw on a post earlier you said moving each layer and not the camera to do parallax is probably inefficient, and I agree it seems a little heavy. The one I'm most curious about is changing our cameras to use Perspective instead of orthographic. To my understanding with perspective cameras, if we placed all our objects with a certain Z distance this will give us a parallax effect, and we can just still move the main camera. Our game is 2D (not 2.5D) so that would probably require some re-exporting of background images and things to get the right resolution.

    My overall questions are
    1. How well does Procamera2D work with perspective view? Right now our main ProCamera2D utilizes Numeric Boundaries, Zoom to Fit, Shake, TransitionsFX, Rooms, and Rails for one particular level
    2. Are there any settings on the Unity Camera component you recommend that might affect performance drastically for ortho cameras?
    3. Another solution I'm thinking is having all my interactive scene object (player, platforms, items, etc) be rendered with your pro camera 2d. Then have everything in background use a perspective camera to do parallax. Do you think this mix makes sense or even possible?
    4. And any other insights are helpful. Maybe I'm just approaching the problem completely backwards.
    Thanks!
     
    Last edited: Jun 13, 2018
  49. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    860
    Hi @BrothaMan,

    The parallax system shouldn't have an high impact on performance since it's made so that each parallax camera only renders its specific objects. I did some tests when developing the extension and couldn't notice anything. A quick online search seems to find the same results. Are you sure your parallax cameras are only rendering their specific layer?

    Replying your questions:

    1) Using a perspective camera would definitely have a better performance because there's no cost associated. Everything in ProCamera2D and the extensions works exactly the same on either mode (perspective or orthographic).

    2) Just be careful with the number of layers each camera is rendering to make sure you're not repeating layers across multiple cameras.

    3) It's definitely possible and should be quite easy to accomplish.


    Cheers!
     
  50. BrothaMan

    BrothaMan

    Joined:
    May 19, 2013
    Posts:
    57
    Yea I wouldn't think it would have extra cost either but it definitely does. Each camera is culling only a single layer, so it's definitely strange. Going from 6 cameras to 2, gives us about 10+fps increase. I'll do more digging this week and get back to you on my findings.

    Thanks for the insight!
     
    luispedrofonseca likes this.
unityunity