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. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @eddOrnelas To avoid the rotation from being reset by the Shake extension, you need to apply it to the camera container and not the camera itself. When you enable the Shake extension, it will automatically create a parent for it when the level starts. That's the object you need to rotate. You can access it by doing something like:
    Code (CSharp):
    1. ProCamera2D.Instance.transform.parent.rotation = Quaternion.Euler(0, 0, 90);
     
  2. eddOrnelas

    eddOrnelas

    Joined:
    Jul 20, 2013
    Posts:
    9
    Alright, i think i have an idea with your sugestion, may i need insert the camera on a new container object and only rotate the parent object so the camera will rotate too, but on shake only the camera will reset and not the parent
     
  3. eddOrnelas

    eddOrnelas

    Joined:
    Jul 20, 2013
    Posts:
    9
    @luispedrofonseca
    Why if i put the camera on a new parent container like CustomParent so will look like:

    CustomParent > MainCamera

    Then the camera creates a parent for the shake component and will look like this:

    CustomParent > ShakeCreatedParent > MainCamera

    and when i invoke shake, the CustomParent position will change to looks always to the center of the Gameworld like relative position? this is a normal behavior?

    The CustomParent has a predefined position but the position get updated after shake

    Regards
     
  4. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @eddOrnelas You have to apply the rotation to the parent that ProCamera2D automatically creates. You have to access it during run-time with the code I posted above. This is necessary because the way the Shake extension works.
     
  5. eddOrnelas

    eddOrnelas

    Joined:
    Jul 20, 2013
    Posts:
    9
    Even if i apply rotation to that parent, after shake the rotation resets too, and if i put a new CustomParent before that, the CustomParent position and rotation changes

    So i want my camera always be rotated 90 degrees and even if i put that on a empty object with 90 degrees on Z, after Shake that object is getting new position even if i already set a default one
     
  6. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @eddOrnelas What version are you using? I'm testing with the latest version and if I apply a Z rotation to the camera parent on the Shake demo, the camera rotation does not reset after a shake.
     
  7. eddOrnelas

    eddOrnelas

    Joined:
    Jul 20, 2013
    Posts:
    9
    How i can check the version?
     
  8. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    The easiest way is to open the README file on the ProCamera2D folder and check the ChangeLog section.
     
  9. eddOrnelas

    eddOrnelas

    Joined:
    Jul 20, 2013
    Posts:
    9
    Now i see, i have the 1.9.1 version and the new one is the 2.2.0
    I will update and come back with my new tests. :oops:
     
  10. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    116
    Just putting this out there for whoever may be interested.
    I'm using the PanAndZoom extension with the drag pan turned on in a standalone game.
    I was getting unintentional pans in the Unity Editor after I'd click on something other than the Game view window,
    so I added this to the "Mouse drag delta" section in the Pan() function in ProCamera2DPanAndZoom.cs and it seemed to fix it:
    Code (CSharp):
    1.                    
    2. Rect screenRect = new Rect(0,0, Screen.width, Screen.height);
    3. if (screenRect.Contains(Input.mousePosition) == false ||
    4.     screenRect.Contains(_prevMousePosition) == false )
    5. {
    6.     _panDelta = Vector2.zero;
    7. }
    8.  
     
  11. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    Thanks for the tip @djfrail. Even better would be to surround that code with a:
    So the code only runs on the editor. I'll add that to the next release. Thanks!
     
  12. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    116
    I'm using the Cinematics extension and was wondering if there was a way to make the camera stay at the last cinematic target instead of panning back to the original camera position after done playing?

    I'm actually using the Cinematics extension to pan/zoom the camera to a clicked point because it has more easing options. I'm open to suggestions on a better way of doing it. Would be happy to use DOTween, too!
     
  13. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @djfrail At the moment there's no option to prevent the camera from returning to the original position after playing a cinematic.

    However, if your goal is to move the camera "manually", your best option is to have an empty camera target and move it around as you'd like. After starting a cinematic you can put that empty target on the last cinematic position and the camera will go there once it ends.
     
  14. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    116
    Thanks - will give it a shot!
     
  15. djfrail

    djfrail

    Joined:
    Jan 16, 2014
    Posts:
    116
    I ended up using DOTween to animate moving the camera and zooming in (I like the ease curves available in that package.) The camera pans and zooms to the destination point and zoomFactor fine (I'm also using 2D Toolkit.)
    Before playing the animation I set .enabled = false on the ProCamera2D and ProCamera2DPanAndZoom extensions,
    then after the DOTween animation finishes, I set those back to .enabled = true and call proCam2d.MoveCameraInstantlyToPosition(theCameraDestPt).

    I'm having a problem, though, with the zoomFactor getting set back to the old zoomFactor value - what is was before I did the DOTween pan and zoom ani. If I just pan after the DOTween ani, that works fine, but when I zoom, it jumps back to the old value.

    Any ideas on what vars I should set and where? Thanks! I'm pretty much just using Pro Camera 2D to pan and zoom around on a 2d picture... similar to browsing a web page on a mobile device (pinch to zoom, drag to pan.)
     
  16. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @djfrail That's a good question. I think at the moment that wouldn't be possible. The ScreenSizeInWorldCoordinates value on the ProCamera2D class would have to be updated to the current camera size. But unfortunately that value is private at the moment. Please contact me through a PM and I'll make a custom build for you so we can test it.
     
  17. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    I'm facing an issue with the ProCamera2DRooms plugin. I want to be notified when my target leave a room in order to set back specific numeric boundaries. So I disabled "Restore On Room Exit" option to prevent the plugin to restore old numeric boundaries by itself. But event won't be trigger so I changed the ExitRoom method by extracting the OnStartedTransition before the RestoreRoomExit test :

    Code (CSharp):
    1. public void ExitRoom()
    2.         {
    3.             _currentRoomIndex = -1;
    4.            
    5.             if (OnStartedTransition != null)
    6.                 OnStartedTransition.Invoke(_currentRoomIndex, _previousRoomIndex);
    7.  
    8.             if (RestoreOnRoomExit)
    9.             {
    10.                 if (_transitionRoutine != null)
    11.                     StopCoroutine(_transitionRoutine);
    12.  
    13.                 //_defaultNumericBoundariesSettings = _numericBoundaries.Settings;
    14.                
    15.                 _transitionRoutine = StartCoroutine(TransitionRoutine(_defaultNumericBoundariesSettings, _originalSize, RestoreDuration, RestoreEaseType));
    16.             }
    17.         }
    Does that make sense for you ?
     
    Last edited: Nov 10, 2016
  18. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @Kiupe Hi! So, you basically want to be notified also when you leave a room but don't transition anywhere?
     
  19. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi,

    Exactly :)
     
  20. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @Kiupe So you basically want an event to fire when you exit all rooms (i.e. are currently in no room). Right?
     
  21. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    basically yes.

    I modified ExitRoom and EnterRoom in order to have event triggered even if RestoreOnRoomExit is set to false. I also added a line in order to get the current numericBoundaries settings in both methods . I often change numeric boundaries programatically and I want to be sure that the Room plugin will use the new current one and not the one at the initialisation time in case RestoreOnRoomExit is set to true.
     
    Last edited: Nov 10, 2016
  22. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    399
    Don't want to be "that guy", but it's kind of bad form to openly post code that isn't public domain in the forums. You should do this via a private message with the asset publisher. :)
     
  23. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @Kiupe Next version (v2.2.3) will have an "OnExitedAllRooms" event. Please email me if you want early access. Cheers
     
  24. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @wheretheidivides That's a very interesting issue. I've never experienced it but I think it's related with the "Follow smoothness".

    i.e. the dizziness is not caused by ProCamera2D itself, but by the fact the camera is not entirely centred on your target. To test it, simply put the "Follow Smoothness" to zero and see if it still happens.
     
  25. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @wheretheidivides For the parallax to work you have to make sure each layer is only being rendered once. i.e. each camera should only be rendering a specific set of layers. ProCamera2D takes care of that for you on the parallax cameras, but you still have to update your Main Camera by removing the layers you assigned to each parallax layer.

    As for that smear effect it's caused by your background camera render settings. ProCamera2D should set that automatically to Solid Color, but please confirm if you don't have anything else changing it.
     
  26. Zehru

    Zehru

    Joined:
    Jun 19, 2015
    Posts:
    84
    @wheretheidivides hi!

    In a past version I experieced this same dizzy feeling when my trigger boundaries were just a little bit bigger than the camera, and I had a zoom trigger inside of it with basically the same size of the original camera orthographic size. In my case, it was caused by a non smart setup hahahahah.
    Maybe something in your setup of the Procamera2d or in any other asset that you use is making this.
    I highly recommend you to send a sample of the problem( a small project that this problem occurs) to @luispedrofonseca. He will certainly be able to find the problem and make the asset even better.

    PS: I can't imagine how much effort He puts on this asset, but to my mind it's AAA on quality, and indie on price. Just mind blowing, so I hope you'll be able to use it as I am( really enjoying it :D)

    Sorry if I could't help, or If I'm just bothering.
    See ya
     
    luispedrofonseca likes this.
  27. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @wheretheidivides The documentation is still not as complete as I'd like due to lack of time, but my goal has always been to make the extensions as easy to use as possible. I understand that the Parallax extension is probably the most confusing one and more documentation would be necessary. I'll add it to the to-do list.

    Regarding the dizziness feeling, I'd really like to see exactly what you mean. Can you record a video or send me a sample project that replicates it?

    Thanks!
     
  28. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,185
    @luispedrofonseca Do you know if we're able to integrate your plugin with the Corgi Engine or Platformer Pro? This would be really helpful for those who have those 2D platformer plugins, but want the additional functionality of your plugin.

    @reuno and @JohnnyA would it be possible to work the integration in somehow if it is not already possible?
     
  29. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @Ben-BearFish Yes, everything should work perfectly. I've had other clients that used those assets together with ProCamera2D without a problem.
     
    Ben-BearFish likes this.
  30. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    272
    @luispedrofonseca

    Hey there, i've got a noobish question to ask, should be fairly simple. I'm trying to use the Cinematics extension to replace my old homemade cinematics stuff (basically two black rectangles with applied velocity as the letterboxes that move up and down). I must admit procamera2d sports a much more elegant solution, but i'm having troubles. I have some avatars and text, but they appear BEHIND the procamera's letterboxes (they can't be seen). I tried Z axis repositioning, but that doesn't work of course.

    Could you help me since i'm not really into how cameras work? Maybe something with multiple camera, culling masks and sorting layers?
     
  31. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @Kruko ProCamera2D's approach uses a shader to achieve the effect, so everything rendered by the camera will be affected. If you want something to appear above it, simply add a child camera and set its culling mask to something specific to those layers you want to draw.
     
    Oshigawa likes this.
  32. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    272
    @luidpedrofonseca

    great, thanks!
     
  33. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    272
    @luidpedrofonseca

    Hi again, i know this ain't quite the place, but it is regarding your plugin :)

    I added a child camera with a culling mask, even set the sorting layers, but the sprite is still behind the shader. Here are the pics, i don't know where i'm wrong.

    This is the sprite, Sorting Layer is set correctly, never mind the Layer, i've set it to be the same as the child camera culling mask, only not in this screenshot.


    This is the sorting layers panel, Dialogue Layer is on top (the bottom one is rendered on top of the others as far as i know)


    This is the inspector of the child camera
     
  34. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @Kruko Everything is correct except that you need to change the layer of the GameObject that contains the sprite (on top right corner). The sprite sorting layers are for a different purpose.
     
  35. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    272
    Аs i said "never mind the Layer, i've set it to be the same as the child camera culling mask, only not in this screenshot." :)

    I'll check it out again though.
     
    luispedrofonseca likes this.
  36. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    272
    @pedroluisfonseca

    Ah, here's the deal, the camera shouldn't be a child, but a separate object, not childed under main camera which contains procamera2d. Everything works fine now, thanks again!
     
    luispedrofonseca likes this.
  37. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @Kruko Glad it's all sorted now! ;)
     
  38. Zehru

    Zehru

    Joined:
    Jun 19, 2015
    Posts:
    84
    Hi!
    I have Corgi Engine and it works perfectly fine with ProCamera2D :D
     
    Ben-BearFish likes this.
  39. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    272
    One more thing, if some other noob appears with a problem like mine, make sure you check your camera depth :D
     
  40. tucano

    tucano

    Joined:
    Nov 9, 2011
    Posts:
    30
    Hello, is this camera compatible with TouchScript events?

    Can I can the Pan and Zoom function from a Script sending as parameter deltaPosition or screenPosition?
     
  41. nickgravelyn

    nickgravelyn

    Joined:
    Jan 22, 2009
    Posts:
    143
    First off, I love this asset. It's saving me lots of time on my project and really does provide all the camera functionality I can see myself needing.

    That said I think the one big thing that would be nice to see addressed is that many of the components and editor scripts change serialized data automatically. Triggers change their camera reference in OnDrawGizmos, the Rooms editor creates a room if the list is empty, etc. Having editor scripts automatically populate serialized data or components changing serialized properties in OnDrawGizmos is bad form, IMO. Populating data or finding references when the components are created or reset is fine, but after that you want to avoid automatically changing things without user interaction.

    It just leads to some confusion when I delete a reference to an object and it comes back without asking me. This is particularly with the triggers which want to find the camera reference all the time but my camera lives in a separate scene so Unity gives me a lot of cross-scene reference warnings that I can't get rid of without modifying the asset code which is fine but will cause issues down the road when I want to update the asset.

    Anyway none of this is big breaking stuff, but it would be some nice polish to see it get cleaned up. :D
     
  42. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Hi,

    I'm interested in purchasing your asset (EDIT: purchase done!) I watched all the demos, and a customer of yours suggested me to use your system with the Corgi engine, instead of relying on its camera implementation (which falls a little behind, to be honest).

    This user also showcased me your product with a video, which seems to be handling pretty much everything I need.

    For my project I'd need:

    1) Smooth (&configurable) is the keyword
    2) Scriptable
    3) Must anticipate and zoom out when moving, centering an zooming back in when idle (maybe keeping the offset)
    4) Should not trigger the camera movement unless the character moves a certain distance away in the opposite direction
    5) Should be able to force a "zoom to fit" behaviour
    6) Should be able to define areas in which a certain zoom level and bounds are needed (zoom should eventually)
    7) Accomodate to make sure the camera doesn't get outside the boundaries
    8) Must be cross platform (Android+iOS) and be mobile friendly
    9) Should implement ground shakes
    10) Should implement fading in and out or transitions (maybe extendable)
    11) Should possibly (not required) be able to define generic parameters from zone to zone to be tweened to interpolate certain FX (bloom intensity, sun intensity), as well as background camera color, FOV, DOF, ambient Color
    12) Should, along with points from 1 to 11, be able to override everything and zoom on the actors taking part in a conversation by centering on both of them gracefully, while still respecting the bounds of the room (I have got indoor corridors with dialogues, and I have to do some closeups when using Dialogue Engine
    13) Possibly blend well with Dialogue Engine, Corgi Engine, Spine (in regards to the renderer bounds).

    Is this miracle possible? :D
    Which points does Pro Camera 2D handle?

    14) I see that there are lots of "Extensions". May I use an arbitrary number of them together (like above) and expect a robust behaviour?
    15) I need this camera as a prefab, possible persistent among the whole game. Is it possible to use it, in a way that it automatically handles all the contents within a scene that has just been loaded into? I need to implement scene to multiple scenes transitions with the possibility of backtracking and a time-switching mechanic (the background and the characters change, possibly also disabling/enabling the "bounds" in the scene, according to the era the player's currently on. Can this be done at runtime?

    Thanks for your time :)

    Kind Regards,
    Alessandro Salvati
     
    Last edited: Nov 29, 2016
  43. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,750
    This looks like a great asset and exactly what I need for my 2D game projects. I'll be picking this up and giving it a try this evening.
     
  44. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,750
    I picked this up last night and so far it's looking really good. There are some great camera extensions that are useful for several of my projects. Great work.
     
  45. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    First of all, sorry everyone for the late response. The Unity forum sometimes forgets to send me notifications. :/

    @tucano I'm not familiar with TouchScript but I don't see a reason why it wouldn't work.

    @nickgravelyn I'm very interested in sorting that out. Can you please contact me through the support form on ProCamera2D's website?

    @NeatWolf I already replied your email that (hopefully) answers all your questions.

    @magique Thanks! ;)
     
  46. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,750
    I have questions regarding Triggers. First of all, I assume that the Rooms examples were done with Zoom triggers. I need a Rooms kind of functionality in my game, but I have a couple of differences. Instead of zooming automatically, I want the player to trigger it. I have an area with several room shapes and a small representation for the player. When the player hits a room door then I want the camera to zoom in on the room and spawn the objects in the room as well as swap the player for the full sized player. So, in effect I need all of the following:

    1. A way to trigger the zoom in manually.
    2. A callback function when the zoom is complete. I will spawn objects here.
    3. A way to manually trigger zooming back out.

    Is this possible with the current system?
     
  47. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
    @magique The rooms examples are actually using the Rooms extension. You can see an implementation demo on the scene at ProCamera2D > Examples > Platformer > Scenes > Rooms

    The Rooms extension has a "manual" mode that allows you to do exactly that. Just turn off "Automatic Room Activation" and simply call the Rooms component methods for entering and exiting a room.
     
  48. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,750
    Oh, OK. I thought there was a Rooms extension, but I couldn't find it at all in the online docs so I thought maybe it was the Zoom trigger.

    That sounds perfect. Thanks.
     
  49. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    822
  50. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,750
unityunity