Search Unity

[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. nsfnotthrowingaway

    nsfnotthrowingaway

    Joined:
    Feb 18, 2016
    Posts:
    48
    @luispedrofonseca Thanks for the quick response. I think I may have not described my issue well. I do not want any of the targets to leave the view at any time. In the gif that follows. You can see that with Camera Window switched off, every small movement affects the camera (trying to avoid this), but zoom to fit with smoothing of 0 works to make it impossible for the character to reach the border of the screen (perfect). With Camera Window switched on, the small movement problem is fixed, but the character can easily leave the screen. I want it to zoom to fit, but for the Camera Window to stop it from scrolling only if all of the Camera Targets are inside the Camera Window:
     
  2. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @nsfnotthrowingaway I'm sorry but I'm still confused with what you're trying to achieve. Any how, the Camera Window plugin always takes in consideration the camera center and there's no option to make it work other way.
    I believe that your use-case (although I don't fully understand it yet) would be a perfect fit for a custom extension if you feel comfortable with some coding.
    If you explain better your goal I can point you in the right direction.
     
  3. nsfnotthrowingaway

    nsfnotthrowingaway

    Joined:
    Feb 18, 2016
    Posts:
    48
    @luispedrofonseca ok. After poking around in the code for a bit trying to make a custom version of the ZoomToFit and CameraWindow, I think I have a better way to frame the problem.

    First off, I think the issue is with ZoomToFit, and not CameraWindow. I just want it to zoom to fit all of the targets, regardless of where the camera is. In the screenshot below, there is no CameraWindow, just ZoomToFit, but I turned up the main camera's FollowX and FollowY smoothing - so the camera isn't immediately in the center point of the players.

    You can see that the players are within the boundaries of zoom out, so it's not going to zoom out further, even though one of the players is not on the screen at all. I'm trying to make it so the Zoom To Fit zoom out and zoom in boundaries are centered on the current position of the camera, not the center position of the players, or put another way, I want Zoom To Fit to always zoom to fit all the camera targets even if the camera isn't in the center of them:
     
    Last edited: Jul 19, 2017
  4. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @nsfnotthrowingaway Have you tried lowering the Zoom In and Zoom Out smoothness values on the ZoomToFit extension? That should give you the result you're looking for.
     
  5. nsfnotthrowingaway

    nsfnotthrowingaway

    Joined:
    Feb 18, 2016
    Posts:
    48
    [EDIT: Got it working]

    @luispedrofonseca yes. In the screenshot above, the zoom in and zoom out smoothness values are both zero, and it stays at that zoom level while the camera slowly pans into view, unless I move the characters closer together or further apart. Once the camera gets back into the center of all the players it's zoomed out to the right level, but until it does, the zooming and unzooming doesn't correspond with the players being on screen.

    To replicate, just load up the platform - zoomToFit scene, and turn up the x and y smoothing for ProCamera to 10, and turn the zoomToFit smoothing to 0. Then run quickly from one side of the level to the other.
     
    Last edited: Jul 20, 2017
    luispedrofonseca likes this.
  6. nsfnotthrowingaway

    nsfnotthrowingaway

    Joined:
    Feb 18, 2016
    Posts:
    48
    @luispedrofonseca Got it working. The gif below shows it with the camera position compensation disabled and enabled. It's pretty useful and works with the CameraWindow and presumably the other position and position delta changers as well. I'm sure you can manage it yourself, and it was only a few lines of code once I figured out the issue, but if you want to add the option to the extension and save a few minutes, I can PM you the changes. Regardless, thanks for making this awesome asset. Saved me a ton of time and works great.
     
    Last edited: Jul 20, 2017
    rrahim and luispedrofonseca like this.
  7. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
  8. nsfnotthrowingaway

    nsfnotthrowingaway

    Joined:
    Feb 18, 2016
    Posts:
    48
    luispedrofonseca likes this.
  9. joelcarlson

    joelcarlson

    Joined:
    Apr 7, 2014
    Posts:
    47
    Hey there, Luis! Is there a way to change the rendering layer for transition effects? Right now I have it rendering under some UI elements. Thanks!
     
  10. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @joelcarlson By default, image effects are not applied on the UI. Not just ProCamera2D's transitions effects but any image effect in general. To circumvent it you need to:

    - Create a second camera (regular Unity camera) and call it for example "UICamera".
    - Make it a child of the ProCamera2D camera and set its position to (0, 0, 0)
    - Set the UICamera "Clear Flags" to "Don't clear".
    - Set the UICamera "Culling Mask" to only the "UI" layer.
    - Set the UICamera "Depth" to 1.
    - On the ProCamera2D uncheck UI layer on the "Culling Mask"
    - Add the TransitionsFX component to the UICamera instead of the ProCamera2D. You can simply move it from one to the other, or remove and add it manually.

    The effects will now be applied to the UI camera, but since that camera is rendering on top of the main camera it will seem like the effect is applied to both. Let me know how it goes.
     
  11. Novodantis

    Novodantis

    Joined:
    Nov 12, 2009
    Posts:
    95
    I just tried this out, but no luck. It seems the UI is rendered even if I cull the UI layer on all cameras. As another check, I tried disabling all cameras but my UI is still drawn (and updates in response to game actions)
     
  12. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @Novodantis That should work. I've just tried it myself without any problem. What Unity version are you using?
     
  13. Novodantis

    Novodantis

    Joined:
    Nov 12, 2009
    Posts:
    95
    5.6.0f3, so not the very latest admittedly. Any idea if rendering of the GUI overlay is something that's recently changed?
     
  14. joelcarlson

    joelcarlson

    Joined:
    Apr 7, 2014
    Posts:
    47
    Thanks for the response! I'll try it out!
     
  15. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @Novodantis 5.6 should work just fine. Get in touch through the support form and send me your invoice. I'll make a sample scene for you.

    @joelcarlson Let us know how it goes.
     
  16. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    370
    Hello Luis,

    I started to play a bit with Pro Camera 2D. So far it seems pretty intuitive.

    Is there a way to make the script to rotate the camera on the Y axis so my object always faces "forward"?

    Basically I have a top-down camera that is following an object. At one point let's say that my object will "turn right". Is it possible for the camera to detect this movement so the camera itself will also rotate?

    Thank You

    /PET
     
  17. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @GamerPET There's no option at the moment to automatically detect targets rotation. Also, ProCamera2D doesn't handle rotations outside of the pre-defined axis. It will follow your objects and some extensions might still work but it's not officially supported. Support for rotated cameras (at any angle) will come in a future update.
     
  18. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    370
    Ah... damn. This means that I need to get a bit creative to accomplish something that I'm trying to do.

    Thanks for the info.
     
    luispedrofonseca likes this.
  19. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    370


    A bit hardcoded, but I managed to make the camera rotate. I get the rotation of the Tram ... and I update the camera rotation to be the one of the tram.

    It works decently... but it's not really smooth. + if I only have a short curve that goes left/right slightly it will rotate teh camera of course where ideally you would only want a small movement left/right and not an actual rotation.

    Anyway... just wanted to leave this here just in case someone else is wondering how to do it.

    EDIT: Another small downside to this is that the Forward Focus extension will not really work.
     
  20. poliman

    poliman

    Joined:
    Feb 5, 2015
    Posts:
    29
    Hi,
    how to use more then one camera?
    I have 2 or more active cameras, and on everyone there is ProCamera2D script and every camera has different settings Pan, Boundaries
    for example I have 3 cameras
    1. When all cameras with ProCamera2D script are active from start, one of them is assigned with 3 targets PC2DPanTarget, and it is unable to pan
    2. When only one camera (Gameobject) is Active from start, and the rest is turned on thru script, all cameras get assigned their tragets, but when you move first pan it affects rest of cameras targets, and have to MoveCameraInstantlyToPosition to default position everytime I switch camera.

    What is the right setup for multicamera scene?
     
  21. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @poliman Typically multiple ProCamera2D's should not interfere with each other. Although, in the case of PanAndZoom extension there appears to exist some kind of bug. I'll take a look and get back to you as soon as possible.
     
  22. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @poliman It took me a bit to sort this one out, but the multiple camera support for pan and zoom is finally ready! Please take a look here:
    https://twitter.com/lpfonseca/status/898608409364185088

    This will be part of the next release. If you don't want to wait for the Asset Store approval please contact me directly with your invoice PDF and I'll send you a version.
     
    magique and rrahim like this.
  23. CosmicBoy

    CosmicBoy

    Joined:
    Apr 16, 2014
    Posts:
    35
    I cannot get the supported Playmaker actions to activate for some reason, the scripts are in the project, I've set the scripting define symbols and I tried re-importing and restarting unity but no luck.
    upload_2017-8-24_16-23-29.png
     
  24. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Is there the capability of using the secondary joystick to peek up or peek down? For example, I am controlling my character movement using the left joystick, but I want to be able to have the camera shift up or down a little bit if the player pushes the right joystick up or down so they can peek at what's up or down in the scene. Is that something built-in to Pro Camera 2D?
     
  25. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @CosmicBoy With the latest ProCamera2D version (2.4.6) you shouldn't need to add anything. If you have PlayMaker installed you should see ProCamera2D's action in there.
    What version are you using?
     
  26. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    magique likes this.
  27. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    luispedrofonseca likes this.
  28. ahmed_decoy

    ahmed_decoy

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

    I have an enhancement request. For ProCamera2D Parallax component, any chance you can enable the user to use separate speeds for "Parallax X" And "Parallax Y" values?

    We are currently building a level where we don't want our Parallax Y strength to be as strong as the Parallax X.

    Is this feasible?

    Thanks!

    Ahmed
     
  29. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @BrothaMan That's not a very common request and it will cause a weird looking behaviour on most situations. This means I don't think it's a good option to give to the users.
    In this case you should create a custom extension (simply duplicate and rename the Parallax extension) and do the necessary changes on your side. It should be very straightforward to implement if you have minimal code experience.
     
  30. ahmed_decoy

    ahmed_decoy

    Joined:
    May 19, 2013
    Posts:
    58
    K I figured that it might not be a common use case. I'm very familiar with your source code and know exactly where to make the changes so I'll go ahead and make a custom extension. For our case I don't think it will have weird looking behavior but I could be wrong. I'll give it a shot and let you know how it goes.

    Thanks!
     
    luispedrofonseca likes this.
  31. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
    @luispedrofonseca

    Hello, I'm considering using ProCamera2D and I've got a questions if you can help me please. :)

    When using Pixel Perfect extension, does it also supports pixel perfect UI? I couldn't find any mentions of this, is there a helper script to manage Unity UI and/or UI elements too?

    Thanks!
     
  32. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
  33. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
    Thanks for the reply but it's not the same thing, it merely snaps pixels.

    If I get that right when I have a low res base image, ProCamera2D will scale it 2x, 3x, etc. to fit the screen depending on the resolution of the device.

    But when put an UI on top of that it won't be pixel perfect unless UI is scaled properly. Even if I use constant pixel size in canvas scaler there is scale factor parameter, I was hoping that ProCamera2D drives it with a helper script to match it's current pixel perfect scaling or something like that.
     
  34. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @PixelEnvision You're right. ProCamera2D won't help you with that. That use-case never occurred to me but it makes a lot of sense. All you'd need is the current scale from the PixelPerfect extension so you could apply it to the CanvasScaler, right?
     
  35. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
    Yes, something like that. :) I think it can be best imagined as a custom canvas scaler that replaces default one, works based on the scaling info from the pixel perfect extension.
     
  36. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @PixelEnvision Replacing the default CanvasScaler would be quite risky and a lot of work to maintain. It's a lot simpler to just add a property to the PixelPerfect extension that gives the current scale and then apply it to the CanvasScaler. In the next release I'm going to add that property.

    Since this is not a common use-case I don't think it's worth to add a new component to the library, but it will be straightforward to do on your side.
     
  37. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Can the rooms fade to black while moving the camera to the new room?

     
  38. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
  39. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    Hey, guys! I'm making a platformer and was wondering if there was a quick way about making the camera "look" up or down if I give up or down on the vertical axis input. I'm also using corgi engine and their camera has that feature but lacks all of the other cool features procamera 2d has so I'm using procamera instead, but simply wish it had that single feature. Any idea what I should do? Thanks in advance!
     
  40. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    nosajtevol likes this.
  41. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Can you also make it work in combination with the cinemachine?

     
  42. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @Lars-Steenhoff I haven't had the time to familiarize myself with Cinemachine. However, I don't see anything in there that isn't achievable already by ProCamera2D.
    Can you please tell what would you be interested in?
     
  43. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    mostly in transitioning in combination with unity timeline. so to be able to make a intro sequence and then seamlessly transition to the game camera.
     
  44. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @Lars-Steenhoff I'm going to have a look at that possibility. Thanks for the heads-up!
     
    GamerPET likes this.
  45. nosajtevol

    nosajtevol

    Joined:
    Jun 28, 2012
    Posts:
    219
    luispedrofonseca likes this.
  46. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    Hey guys, here's a quick preview of a the next extension coming up in the next release - Content Fitter!



    It helps you fit anything on screen and easily control how it's going to look across all different screen sizes. Hope you like it!
     
    Zehru likes this.
  47. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    In one of our current game we are using ProCamera2D and the Room plugin. We are using the later by creating and deleting room dynamically. It works great but there is one downside, " OnStartedTransition and OnFinishedTransition" are based on room indexes so when removing room dynamically existing room indexes changes so the indexes returned in the events are not valid anymore (not matches the prev and next room because the room array has been updated). It would have been great to have the room IDs returned in those events (or new ones ?) because those should not change.

    Does that make sense ?

    Thanks
     
  48. Pvt_Hudson

    Pvt_Hudson

    Joined:
    Jan 20, 2016
    Posts:
    41
    There's 25x of the below errors upon updates...

    Assets/ProCamera2D/Code/Extensions/ProCamera2DCameraWindow.cs(6,6): error CS1614: `HelpURL' is ambiguous between `HelpURL' and `HelpURLAttribute'. Use either `@HelpURL' or `HelpURLAttribute'

    is there someway to easily rectify this, without having to modify 25 files manually?

    (Unity 2017.1.1p3)
     
  49. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @Kiupe Yes, it makes sense. But you should be able to do that by using something like:
    Code (csharp):
    1. yourRoomsExtension.Rooms[currentRoom].ID
     
  50. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    945
    @ch0kk0 I suspect that issue is a "bug" with the Unity patch release you're using where the conditional compiling tag I used is not defined - "#if UNITY_5_3_OR_NEWER". If you update your Unity to something else like Unity 2017.1.2 that issue will go away.

    Anyhow, I've updated the attribute so we don't get conflicts in the future. Feel free to reach me directly with your invoice and I'll send you an updated version, if you don't want to wait for next release or update your Unity version.