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

    magique

    Joined:
    May 2, 2014
    Posts:
    3,757
    Is there any way to synchronize multiple cameras? I have 2 cameras in my scene that each render different layers. I have a Pro Camera 2D on my main camera, but it gets out of sync with my other camera. I tried putting another Pro camera 2D on the other camera and set the exact same properties, but it doesn't give me the desired results. I still see the same out of sync rendering.
     
  2. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    399
    Could you just parent one to the other?
     
  3. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,757
    I have no idea. That seems a bit strange and I have no idea if it would work.
     
  4. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @magique Parenting the 2nd camera to ProCamera2D should work perfectly. Assuming your 2nd camera doesn't have independent movement.
     
    magique likes this.
  5. BrothaMan

    BrothaMan

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

    Starting to use the Rails extension. What method is recommended to add targets to the Rail extension during initialization (before the Awake is called in Rails), and during gameplay?

    My code is breaking because I'm noticing when using AddRailsTarget(), this also adds targets to the ProCamera2D component. So my next thought would be to call AddRailsTarget() and not ProCamera2D.Instance.AddCameraTarget() since that is already handled.

    However, I noticed in the awake of the the Rails extension, it once again adds a cameraTarget to a dictionary held inside Rails called _cameraTargetOnRails, which it errors since the target has been added here already.

    So I'm really not sure what the best approach is as far as adding targets to the Rails camera without it breaking.

    I looked at your demo scene, which had the target already added to the Rails extension. This gave me a better understanding how it works, but having a target already added in the editor isn't an option for our scenario. The dropzone for adding targets to Rails, just adds the Target to the CameraTargets array, so maybe that's what I should do in my initialization method?

    A bit confused in the end. I guess I just need direction on best API's to use to do the following:
    1. Add target to Rails during initialization (Before the Rails awake call is made)
    2. Add target to Rails during gameplay
    3. Remove a Rails target during gameplay (Is this supported?)
    Thanks!
     
  6. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @BrothaMan When using the Rails extension you should only add targets to it and not on the ProCamera2D core.
    So:
    1) You can't add rails targets before the Awake method of the extension. The component needs to initialise first.
    2) Simply use the "AddRailsTarget" method.
    3) That method is not available at the moment but I can easily add it if it's suitable for you.
     
  7. BrothaMan

    BrothaMan

    Joined:
    May 19, 2013
    Posts:
    47
    @luispedrofonseca K makes sense, I can make sure the the target is added after the Rails awake.

    For #3, that would be great! Our common example is 4-player co-op side scroller, one player dies, they should be removed from all Pro Camera 2D targets. So that would definitely be required for us.
     
  8. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @BrothaMan I've just added a new method (RemoveRailsTarget) that will be included in the next release (v2.2.5).
     
  9. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Hi,

    I was looking for a way to "CenterTargetOnStart", but a frame later, when everything gets initialized.

    I can see the code inside the Start method, but don't want to change the source code.

    Since I'll be calling the CenterOnMainChar method from an external component, and the camera is attached to an object that doesn't get destroyed between scenes, I'd like to be able to center the camera on the player as soon as the scene is considered to be initialized by my game logic.

    Long story short: I'd like to use a public method for centering on the targets immediately, at any time.

    I couldn't find it anywhere in the code, which seems very strange to me (sometimes you just need to snap the camera position)

    Am I missing something or there is actually a clever solution to this? I don't want to change the source code, the start method gets called only when the camera is created (once at the start of the game) and I don't want to inherit from the camera (I'm pretty sure the inspector wouldn't be the same). Also, I can't even force call the Start method because it's private.

    What do you suggest? It's not urgent, I may have 1 week before it gets critical.

    Unrelated question: is the next update going to break something? Is it still going to support v5.4? Do you have any eta about when the Asset Store could approve it?

    Thanks for your time :)
     
  10. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @NeatWolf There's a method for that on the core class, it's called "Reset". You can find out more about it here: http://www.procamera2d.com/user-guide/core/#reset

    Regarding updates, don't worry. I'm not planning to drop support for any version any time soon, so every version since 4.6 should work fine. Also, I always try out the betas as soon as possible to make sure when a new version comes out, ProCamera2D is compatible.
     
  11. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Hi Luis,

    yes, I saw that, but it also has a collateral effect I don't want:
    I've got a global camera for the whole game.
    I believe the only way to center the camera on the target (which is hopefully not reset) is to save all the settings about all the extensions and triggers, call the Reset method, and then restore everything to its previous state.

    I was also considering to extend the class, but most of the fields and methods are either private or public, I can't override anything! :(

    Could you please add a simple CenterOnTarget(s) method in the next release and make almost everything protected or virtual?

    The quickest way for me is to change the source file, which is definitely the last thing I want to do.

    Apart from that, I'm really enjoyin the asset :)

    When are you going to release next update? I may wait for that, if it's not too distant in time.
     
  12. CosmicBoy

    CosmicBoy

    Joined:
    Apr 16, 2014
    Posts:
    27
    Hi Luis,

    Is there any way to skip an entire cinematic? Like GoToNextTarget except a method that includes skipping it's given Start and End Duration entirely and reverting back to normal?

    Great product btw 10/10

    - Thanks :)
     
  13. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @NeatWolf Yes, that is correct. The Reset method also "resets" the extensions.

    You could achieve what you want by using the "MoveInstantlyToPosition" method and passing your targets position. However, you method suggestion for "CenterOnTargets" is quite good. I'll add it to the next release. I can't predict the release dates because it takes a few days for review. It's a pain in the @ss but it's out of my control. There's currently an update in the queue so the next one I should submit it next week.


    @CosmicBoy You can use the "Stop" method of the Cinematics extension.
     
    NeatWolf likes this.
  14. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Yes, I guess I have no choice but to use "MoveCameraInstantlyToPosition", I'll try to replicate all the centering and offsets I set up in the extensions, a native solution would have been definitely better.

    What about the virtual overridables methods, and protected fields, could you please add them as well? The main class (and probably the extensions as well, I haven't checked) is a bit "sealed" and it's almost impossible to create useful subclasses from it without having to change the source - which is definitely not a thing many would like to do.

    Thanks for listening to feedback! :)
     
  15. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @NeatWolf Yes, I'll look into making the core class more flexible. Send me an email through the support page (http://www.procamera2d.com/support) with your invoice number and once the new version is ready I'll send it to you so you don't have to wait.
     
    NeatWolf likes this.
  16. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Sure!
    Cool!
    Thank you!
    (I only wished Unity could just list my invoice numbers in a easy to access list - it's a pain having each time to browse through emails - I may also accidentally lose - to find it!)
    (And it would be cool for publishers to automatically know if someone in the forum bought some of their assets - to avoid giving support to pirated copies and saving a lot of time in looking for invoices and having to verify them)
     
    luispedrofonseca likes this.
  17. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    399
    Just to add to this. I found myself needing something similar to NeatWolf. I think it'd actually be good to have an overload of Reset() where we could specify which things to reset. I've found use cases in my project for all combinations.

    i.e.

    Code (CSharp):
    1. public void Reset(bool centerOnTargets, bool resetSize, bool resetComponents)
    You might think of a better way to implement, but I've added this in myself for now :)

    EDIT: After playing around with this... I think actually I can get by with just the current Reset method and MoveCameraInstantly
     
    Last edited: Dec 19, 2016
    luispedrofonseca and NeatWolf like this.
  18. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Unfortunately just centering isn't enough with Extension moving forward or offsetting the camera.

    I'm currently using the MoveCameraInstantlyToPosition to center the camera on the player, but a few extensions like ForwardFocus and CameraWindow are keeping an offset even if I move or teleport the player facing in another direction.

    So, if I enter a door facing right, the camera is anticipating the player by moving to the right, but even if I teleport the player elsewhere in another scene, facing left, the camera is still anticipating on the right.

    It would be cool to be able to center the camera also centering when possible all the other extensions. I'm not talking about a full reset, just tweaking the internal values of the camera and all active extensions so that it gets centered (respecting the fixed offsets) when teleporting.

    It would be also nice that after a teleport the focus could be totally moved on the left or on the right as per ForwardFocus settings, to reflect player's facing. So probably a few extra methods for the ForwardFocus would be cool to have. Maybe passing a Vector2 as a direction to push the ForwardFocus at its maximum in that direction.
     
    luispedrofonseca likes this.
  19. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    399
    But isn't that what the current Reset method does? It calls the OnReset callback that resets PC2D components like forward focus. Unless I'm misunderstanding? :)
     
    luispedrofonseca likes this.
  20. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    I honestly don't know, haven't tried it yet or delved into the code to check. When I hear about "reset", I think about reverting all parameters to their default settings that may different from the setup I currently have at any moment.

    I wouldn't like everything to be reset, just part of the runtime values to achieve centering, or moving the camera according to the facing of a character. I'm trying to do that manually, but it's approximate, and as soon as I teleport the camera there is still some camera movement & adjusting going on, that I'd like to get rid of. A native function able to do that should avoid this behaviour, thus setting all internal variables that the camera doesn't need to adjust but just stays still when teleporting away.

    It could be also useful to set the camera initial panning when starting or restarting a game - you don't want to start a game with the camera already moving to snap into position.
     
    luispedrofonseca likes this.
  21. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    399
    Well that's what the Reset function does; it resets the runtime state of the asset - it doesn't change any of the settings you set in the inspector. I'd suggest trying it in your game and seeing if it behaves as you'd like, because it seems to me it does what you want.
     
    luispedrofonseca and NeatWolf like this.
  22. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Sort of. It also resets the camera orthosize, which is unwanted for me, but I can revert it back right on the next line.
    Thanks! :)
     
    luispedrofonseca and flashframe like this.
  23. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    Thanks for the discussion @flashframe and @NeatWolf. The "Reset" method is probably badly named as it might create some confusion on what it does. Like flashframe said it only resets the values of the extensions to their start values, not default.

    Any how, for now I've extracted the following methods from the "Reset" method: "CenterOnTargets", "ResetSize" and "ResetExtensions". Also added optionals for resetting the size and resetting the extensions on the "Reset" method. This should make things more flexible.

    @NeatWolf Please notice you can reset each extension manually using its "OnReset" method.

    Thank you all for the suggestions! Please keep'em coming! ;)
     
    NeatWolf likes this.
  24. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    That's the spirit! ;) Thank you!

    It would be nice to choose if resetting ProCamera2D would leave the actual Camera component unchanged (such as orthosize and such). I know I've got a very specific setup (global camera for all the game), so I'm tweaking the camera programmatically on the start of each scene. But since I am forced to tweak Camera settings in a later moment, I also lose all its settings.

    It could be nice if ForwardFocus had a method to immediately push the view at the maximum amount possible towards a certain direction, so that on scene start it is already still, offsetted properly, and waiting the tracked object to move.
     
  25. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @NeatWolf Using the "Reset" method of ProCamera2D won't interfere with Unity's Camera component if you set the "resetSize" option to false.
     
    NeatWolf likes this.
  26. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Thanks! Since I believe I'm using the latest version from the UAStore, I suppose it's a new feature uploaded somewhere else, right? :)
     
  27. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    Yes, it's only for v2.2.6 (v2.2.5 still on the queue for approval). I'll send it to you as soon as possible so you don't have to wait.
     
    NeatWolf likes this.
  28. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Cool! Thanks! If you have a private forum for beta versions, count me in! :)
     
  29. Sparty93

    Sparty93

    Joined:
    Dec 6, 2015
    Posts:
    2
    I know this is only 2 / 2.5D, but is there anyway to rotate the camera in the cinematic extension? My game is 2.5d but because it is built entirely in 3d in Unity, I am trying to create a cinematic transition to look at a scoreboard that will move to a target and rotate 90 degrees during the EaseIn, then move and rotate back to it's original position. I am thinking I can probably do it with a custom trigger but thought I would ask first.
     
  30. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @Sparty93 In that case you can simply turn off ProCamera2D (disabling the core component), animate the camera as you please, and then enable it again once your animation is complete.
     
  31. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    273
    Hello @luispedrofonseca

    i'm having troubles with playmaker, but they are so slow in responding to anything there that i decided to drop you a message here.

    A problem happened when using Unity 5.3.5f, i just stopped seeing the ProCamera actions in Playmaker and all the FSM's using ProCamera actions report a missing action, i checked the scripting define symbols, everything's fine there. I tried re-importing the Playmaker asset, but the infamous glitch with hierarchy view happens (it messes up and it can't be fixed). I tried it once again but to no avail. So i decided to install latest Unity version, 5.5.0f3. Playmaker is latest too, 1.8.3, so is ProCamera, 2.2.5.

    Unfortunately, reimporting the Playmaker in this version seems to fail, so i'm trying to find an answer on the other side until Jean gives me a proper advice. Is it possible to re-import ProCamera but leave everything i have done intact?

    I know it's Christmas so i'll be waiting for some time for answer, but take your time, it's holiday :)
     
  32. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @Kruko I've imported Playmaker 1.8.3 and ProCamera2D 2.2.5 into a new Unity 5.5.0f3 project and everything worked correctly. However, please notice that Playmaker requires you to extract a file after importing the package (under Playmaker/Installation folder). I don't know why they opted for this but I guess they had their reasons.
    Let me know if that helped. Cheers!
     
  33. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    273
    @luispedrofonseca

    Ah, sorry for taking me so long, so much work to do before New Year. Check this out, there is an action to be chosen from the actions menu, but it's missing in the FSM. I'm running Update All Loaded FSMs, hope it will sort it out, it looks like it's missing the references, there are loads of other error. Thanks for a quick answer, i'll have to wait Jean on the Hutong Forums for this, PC2D is all good.

     
    luispedrofonseca likes this.
  34. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @Kruko OK, let me know how it goes and if there's anything I can do from ProCamera2D's side.
     
  35. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    273
  36. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Hi again @luispedrofonseca ,

    I'm now working on a poolable crowd system that has to work in 2D and has to be as fast as possible since it's supposed to be working on mobile. (2D, side view, orthographic, but may turn into perspective depending on the everchanging design document *sigh*)

    I'm probably going to have objects following a path (since I have slopes). They simply disappear when entirely offscreen and they respawn back from the other side with aesthetical changes.

    I think I coudl simple use a simple difference between the center of the screen X coordinate and the one of the object, and check if it's greater or not than orthoSize, but since I may also have spawn points that only work when off screen:

    is there a function in ProCamera2D to detect (with some accuracy) if an object/ point in space is inside the frustrum/shown in the camera? Of course I only want spawn points to generate crowd element when not rendered.

    I think it's a common Unity question and there are several approaches, but if it's already there, in ProCamera2D,. I'd really love to save some time ;)
     
  37. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
  38. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    Yeah, I've been there. the fact about OnBecameVisible and viceversa is that items that get spawned outside the camera never have their OnBecameInvisible method called. So you can only check it if you have an actual rendered object that's moving out from the camera. There's a workaround for that, that I used in another game, but I was hoping there was a native ProCamera2D function to handle that.

    Since it's quite common problem to solve if you have a camera and want to do some optimization, could you consider this a feature request? A new Extension that handles object visibility, or a function that mathematically returns a bool about a certain object being on camera or not (both in ortho and in perspective)? Like bool InCameraBounds(Vector3 point)?
     
  39. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @NeatWolf Yes, that would be a nice feature to have. Can't make any promises on release dates at this point though.
     
    rrahim and NeatWolf like this.
  40. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    882
    No worries. You're doing a great job, thanks for your product!
     
    luispedrofonseca likes this.
  41. LarryWP

    LarryWP

    Joined:
    Oct 31, 2014
    Posts:
    57
    I just bought this asset last night, and the next morning I am amazed at how easy it is to use and how much this does! It's a great idea to have the Extensions the way you do, that makes it easy. Click them on and off and all the settings have tooltips done well. I am currently using your online User manual and it could not be better. I believe in giving praise to devs that make good assets, and this is one of the best I own. Thanks a lot!
     
    luispedrofonseca likes this.
  42. LarryWP

    LarryWP

    Joined:
    Oct 31, 2014
    Posts:
    57
    I notice that after I tried Pixel Perfect, then deleting the plugin, it stayed on. I had to close Unity then reopen it for it to go away. I never saved when I tried it, so that helped.
     
    luispedrofonseca likes this.
  43. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @LarryWP Thanks for your kind words.

    Once you activate the PixelPerfect extension it will automatically resize your camera to a pixel perfect size. After you remove the extension, you do have to reset back the camera to its original size if intended.
     
  44. LarryWP

    LarryWP

    Joined:
    Oct 31, 2014
    Posts:
    57
    I should have known that. What a dingbat. Thanks for the reply!
     
    luispedrofonseca likes this.
  45. yukamui

    yukamui

    Joined:
    Nov 19, 2013
    Posts:
    11
    Hello! I am a new user of the ProCamera2D and loving it.

    I am having problems trying to use the Repeater and Parallax features at the same time. I am trying to create an infinite seamless background with parallax.

    I have tried attaching repeaters on each of the parallax cameras, but I am wondering if what I want is achievable at all (Since Characters should be on the "ground" layer and that layer should be repeated too..)

    Anyone here can point me in the right direction?
     
  46. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    Hi @yukamui!

    When you have the Repeater and the Parallax extensions enabled, the Repeater extensions shows an additional parameter called "Camera To Use". If you want to have a repeated object on a parallax layer, you should pass the corresponding parallax camera to that field.
     
    yukamui likes this.
  47. yukamui

    yukamui

    Joined:
    Nov 19, 2013
    Posts:
    11
    Thank you so much for the fast reply!

    I didn't notice that field.

    Now I notice that parallax cameras are normal cameras but the repeater ask for a ProCamera2D. Should I attach ProCamera2D components to each of them? Because I am doing that and still having issues and I want to see if I am making the mistake there or in other part of the process.
     
  48. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @yukamui The parallax cameras are just normal cameras and you don't need to add any component to them. The "Camera To Use" parameter on the Repeater accepts any camera.
     
  49. yukamui

    yukamui

    Joined:
    Nov 19, 2013
    Posts:
    11
    I am using versión 2.2.6 and I can't drag a normal camera to the field (I attached a screenshot), I am doing something wrong?

    Also I have the bool ObjectOnStage active, but I get (clones) whenever I modify the repeater parameters. (Should I use the clones and delete the original ones?...right now I delete the clones and it work ok, but I am not sure if this is correct.
     

    Attached Files:

  50. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    829
    @yukamui When you have the Parallax extension enabled, the Repeater extension editor should show you that bottom parameter called "Camera To Use". There you should put one of your parallax cameras.

    Yes, there is a bug related with ObjectOnStage which creates an unnecessary copy. You can delete it and it won't cause any problems. I'm fixing it for next release.
     

    Attached Files:

unityunity