Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    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. yukamui

    yukamui

    Joined:
    Nov 19, 2013
    Posts:
    12
    Thank you very much @luispedrofonseca!! I was trying to change de ProCamera2D.. silly me!

    Thank you very much for your support and thank you creating such an awesome camera.
     
    luispedrofonseca likes this.
  2. huaffinity

    huaffinity

    Joined:
    Oct 28, 2016
    Posts:
    12
    Q) How could I migrate extension data in editor?

    So, I've faced a case of merge conflict with the same scene while collaborating with my teammate.
    He's updated so much rails extension and I have my own shake extensions updated.
    With or without using merge system via version control how could I resolve this?
    Is .unity the only place the extension data stored?
     
  3. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @huaffinity The easiest way is to click on the top-right gear wheel and choose "Copy component". Then go to your final scene and do the same but choosing "Paste component values".
     
  4. huaffinity

    huaffinity

    Joined:
    Oct 28, 2016
    Posts:
    12
    WOW! Great thanks!
    I didn't know copy component would carry data for such case... like scene to scene or project to project still in the clipboard...
     
    luispedrofonseca likes this.
  5. huaffinity

    huaffinity

    Joined:
    Oct 28, 2016
    Posts:
    12
    Q) At some point my Shake extension is broken and can't track down why

    This was before I updated the plugin to the last version and the version I was using was the one just before that.
    The symptom is :
    1. shake is not doing anything more than simple jutting to side once no matter how many iterations.
    2. the presets have been reset and re implementing any presets won't change #1
    3. if I remove Shake component while in runtime and then attach a new one(shake extension) it functions just the way it should.

    Could you give me a hint on this please? I think I've tried enough by myself DX
     
  6. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @huaffinity Do the example scenes work (ProCamera2D > Examples > Platformer > Scenes > Shake)?

    Did you re-parent your camera? Which Unity and ProCamera2D versions are you using?

    Can you send me a (small) sample project that replicates the issue?
     
  7. fugogugo

    fugogugo

    Joined:
    Jun 18, 2013
    Posts:
    12
    Hi,

    I have some specific camera movement which I need to know whether can be done or not via Pro Camera 2D

    so my game will be something like the player is a leader that followed that many minion (top down shooter style)
    I want the camera zoom in and out depend on the number of minion following the player.
    lots of minions -> zoom out
    few minions -> zoom in

    how can this be achieved with Pro Camera 2D?

    Thank you :)
     
  8. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @fugogugo That should be very simple to do. The easiest way to do it is by adding the player and all the minions as camera targets. Then you set the minions "influence" to a low number, so that the camera is still influenced by their position but not as much as the main player.
    To take care of the zoom, you can use the ZoomToFit extension - http://www.procamera2d.com/user-guide/extension-zoom-to-fit/
     
  9. TomLikeABOMB

    TomLikeABOMB

    Joined:
    Dec 3, 2015
    Posts:
    9
    Hi,

    I just updated to Unity 5.5.0f3 and pro camera 2d 2.2.7. I'm getting this error:

    Assets/Utilities/ProCamera2D/Core/Extensions/ProCamera2DPointerInfluence.cs(39,34): error CS1501: No overload for method `SmoothDamp' takes `4' arguments

    in pointer influence, and the same error 3 times in trigger influence. Is there any easy way to remedy this? Thanks.
     
  10. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @TomLikeABOMB Are you sure you have the latest version of ProCamera2D? That bug was solved a few versions ago when I added support for Unity 5.5.
    To be sure, delete the whole ProCamera2D folder and import the latest version again.
     
  11. jacobbijani

    jacobbijani

    Joined:
    Oct 1, 2015
    Posts:
    4
    How would you recommend checking if the ProCamera2D instance exists from another script? I have some code that calls a method on the camera, but should just silently bail if there's no PC2D camera in the scene.

    Right now I'm checking if "ProCamera2D.Instance == null" but that internally throws an error if there's no camera. I'd rather not wrap all my checks in try/catches. Is there a way, or if not would you consider adding, a method to just check if the ProCamera2D instance is available without throwing an exception?
     
  12. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @jacobbijani Unity / C# already has a few methods to achieve exactly that. You can try one of these:

    Code (CSharp):
    1. if (Equals(FindObjectOfType(typeof(ProCamera2D)), null))
    2. {
    3.    // No ProCamera2D available                      
    4. }
    5.  
    6. // This one assumes your camera is tagged as MainCamera
    7. if (Camera.main.GetComponent<ProCamera2D>() == null)
    8. {
    9.    // No ProCamera2D available
    10. }
     
  13. darrennorthcott

    darrennorthcott

    Joined:
    Jun 17, 2014
    Posts:
    20
    Hi, I just updated Unity and now I'm getting this error:
    Assets/ProCamera2D/Code/Extensions/ProCamera2DPositionAndSizeOverrider.cs(38,33): error CS0115: `Com.LuisPedroFonseca.ProCamera2D.ProCamera2DPositionAndSizeOverrider.OnPostMoveUpdate(float)' is marked as an override but no suitable method found to override
     
  14. TomLikeABOMB

    TomLikeABOMB

    Joined:
    Dec 3, 2015
    Posts:
    9
    @luispedrofonseca Thanks! That worked. I just right clicked it and re-imported before. I guess that wasn't good enough.
     
    luispedrofonseca likes this.
  15. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
  16. superspit

    superspit

    Joined:
    Aug 15, 2016
    Posts:
    6
    Hi ,

    I can't seem to get MoveCameraInstantlyToPosition to work. The only extension i'm using is the pan & zoom. But no matter where i put my MoveCameraInstantlyToPosition in code it always moves back to look at 0,0 when the scene is started. Am i missing something? all i want to do is set the camera position after the scene has started.

    cheers

    Johnny

    btw i couldnt get this to submit on your site. I kept getting 405 not allowed. Sry if i spammed you!
     
  17. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @superspit Thanks for letting me know the website form was not working. I've been adding some spam measures and apparently I messed it up. It's fixed now.

    Regarding your issue, the PanAndZoom extension uses an "empty" GameObject to move around. That's why after you call the "MoveCameraInstantlyToPosition" method, it returns back to the same spot.

    To avoid this, you can simply call the "CenterPanTargetOnCamera" method from the PanAndZoom extension, after calling the "MoveCameraInstantlyToPosition" method.

    Code (CSharp):
    1. ProCamera2D.Instance.MoveCameraInstantlyToPosition(NewPos);
    2. ProCamera2D.Instance.GetComponent<ProCamera2DPanAndZoom>().CenterPanTargetOnCamera();
     
  18. superspit

    superspit

    Joined:
    Aug 15, 2016
    Posts:
    6
    cheers, worked like a charm !

    Johnny

     
    luispedrofonseca likes this.
  19. agito1987

    agito1987

    Joined:
    Mar 13, 2013
    Posts:
    27
    Hey,

    Let me start of by saying that I really like you’re asset!

    I have a problem with the parallax component.
    I have everything setup as described in the online documentation.
    (From back to front, every depth has its own layer and low to high value for the speed.)


    When I use speed values above 1 (so that the layers render in front of the camera) everything works as it should. But when I use speed values from 0.1 to 1. The layers don’t display and the main camera is forced into depth only (instead of my solid color mode).
     
  20. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @agito1987 When you have layers with speeds lower than 1, your main camera has to be set to "depth only" in order for you to be able to see the cameras behind it. The solid color mode should be set to your slowest layer which is your last layer.
     
  21. agito1987

    agito1987

    Joined:
    Mar 13, 2013
    Posts:
    27
    Oh yeah that makes complete sense XD


    But I am still not able to make the parallel cameras visible when they are set below speed 1.
    Above speed 1 it works but is my main camera in the background. (And I understand why).

    When the speed is below 1 the main camera is depth only so that I should see the layers behind it.

    But the main camera is the only thing that gets rendered.

    And the render order of the camera gets sorted by the plugin so adjusting the camera depth doesn’t help me.
     
  22. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @agito1987 You might be doing something wrong. Can you please contact me through support (http://www.procamera2d.com/support) and send me a small sample project that replicates the issue?

    BTW, have you taken a look at the example scene at ProCamera2D > Examples > Platformer > Scenes > Parallax?
     
  23. agito1987

    agito1987

    Joined:
    Mar 13, 2013
    Posts:
    27
    I figured it out.

    I am using SSAO pro plugin for ambient occlusion. It works great, but somehow it screws up with the parallax script so that the background is no longer rendered and I get a flashing background.

    Is there a Good AO plugin you know works with your asset?
    (Maybe the plugin: amplify occlusion?)
     
  24. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @agito1987 Unfortunately I'm not familiar with AO solutions out there and I can't confirm which ones work with ProCamera2D. I'm guessing it doesn't work because somehow they have to manually force the camera Clear Flags. You can always ask the asset authors if their plugin interferes with that.
     
  25. jacobbijani

    jacobbijani

    Joined:
    Oct 1, 2015
    Posts:
    4
    Aren't those both sort of unperformant though? The docs for FindObjectOfType say "Please note that this function is very slow." And, generally, it just seems better to me not to go round-about like that when the internals for ProCamera2D.Instance already manage it, but just throw an exception. It's not always *exceptional* that there's no camera instance.

    Basically, would love to just see a "ProCamera2D.InstanceExists ()" method which returns true/false... would really help with my workflow!
     
  26. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @jacobbijani They are. These are to be used on some rare occasions and never on an Update() for example.
    I'll add that method for you.
     
  27. jacobbijani

    jacobbijani

    Joined:
    Oct 1, 2015
    Posts:
    4
    Thank you so much! I'll be able to remove a big pile of try/catch's (which I've heard are performance-drains, themselves. Never ends...)
     
    luispedrofonseca likes this.
  28. basmith

    basmith

    Joined:
    Nov 10, 2011
    Posts:
    17
    Hi, I was just curious if this camera allows for a view-angle that isn't axis-aligned? For a top-down game I'd like to be able to rotate slightly to catch some side-details.
     
  29. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @basmith
    Officially no, meaning that some features might be slightly offset depending on how much your camera deviates from the XZ axis origin. Although you can compensate for some of those deviations by adjusting the offset. Due to this I can’t officially say it works. However, I'm planning to introduce more 3D-ish features throughout 2017, including full support for any camera rotation. I can’t give any release dates at this time though.
     
    rrahim likes this.
  30. basmith

    basmith

    Joined:
    Nov 10, 2011
    Posts:
    17
    ah, ok. so i could do something like pseudocode:

    Code (csharp):
    1. float offset_len = tan(cam_angle)*cam_height;
    2. p2d_cam.offset = offset_dir.normalized * offset_len;
    assuming the cam position is tracking the player, this should offset to center the rotated view. (haven't tested though)

    would that cause any major problems?
     
  31. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @basmith The offset I mentioned is simply a way to move the camera in the horizontal or vertical direction, from the "calculated" target center. It can be used to compensate on the case of a rotated camera but you need to have in mind that some things will be off.

    http://www.procamera2d.com/user-guide/core/#offset
     
  32. basmith

    basmith

    Joined:
    Nov 10, 2011
    Posts:
    17
    gotcha... i can deal with some amount of quirks if you're planning on adding general rotation support later this year.

    thanks!
     
  33. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    I just submitted a new version (2.2.9) to the store. Contains the following updates:

    - Core - Added a static property (Exists) to know if there's a ProCamera2D present in the scene
    - Parallax - Added an option to toggle the parallax layers size adjustment
    - TriggerZoom - The trigger now has precedence over other zoom extensions


    /CC
    @jacobbijani
     
  34. Wambhse

    Wambhse

    Joined:
    Aug 11, 2015
    Posts:
    13
    Hey I have a question, I'm not really understanding the remove target method. I am writing a script so that I can update the camera's targets on the fly, but I am not understanding how to "check" to see if a gameobject / gameobject's transform is being tracked already. And how to remove the gameobject from the list if it is found. Can you please help me understand what code I should be writing to check the "list" of all transforms being tracked, and how to remove only ones with the name or specific tags, if found. thank you.
     
  35. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @Wambhse The targets list is simply a List of CameraTarget's. CameraTarget is a class that holds a few values including the TargetTransform.
    You can manually manage that list using any method you'd like or you can use the AddCameraTarget or RemoveCameraTarget methods to do it for you.
    The AddCameraTarget method also returns a CameraTarget in case you want more granular control.
    You can also use the GetCameraTarget method to know if a specific transform is already on the targets list.
     
  36. Wambhse

    Wambhse

    Joined:
    Aug 11, 2015
    Posts:
    13
    Thanks for the quick reply, Also how would I control the camera's smoothness through code? I didn't see an example code on the website. Thanks again!
     
  37. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @Wambhse You can set like any other field in C#. Simply access it:

    Code (CSharp):
    1. ProCamera2D.Instance.HorizontalFollowSmoothness = .5f;
    2. ProCamera2D.Instance.VerticalFollowSmoothness = .5f;
     
  38. Wambhse

    Wambhse

    Joined:
    Aug 11, 2015
    Posts:
    13
    thanks! perfect.
     
    luispedrofonseca likes this.
  39. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    For the v2.3.0 release I've decided to revamp the Shake extension. Now it has support for constant shakes (great for handheld, earthquake, long explosions, etc), and all presets are saved as files (ScriptableObjects). This means you can easily share presets between scenes, projects or even other colleagues.

    Here's an example of a ConstantShakePreset. This one comes included with the package and it's called "HandheldSoft":

    https://twitter.com/lpfonseca/status/834375601897238529

    And here's how the new editor looks like:
    Screenshot 2017-02-22 12.20.24.png Screenshot 2017-02-22 12.20.44.png Screenshot 2017-02-22 12.21.04.png

    Let me know what you think, if you have any requests or if you'd like to give a go before release.
     
    Last edited: Feb 22, 2017
    Zehru and flashframe like this.
  40. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    743
    Looks great Luis. Does a constant shake still ease out when you stop it? I mean, does it come to a gradual stop or stop abruptly?
     
    luispedrofonseca likes this.
  41. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @flashframe Glad you like it! There's a method (StopConstantShaking) that has a duration parameter so it's all nice and smooth. :)
     
  42. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    743
    Ah perfect. Yes, that's a really useful addition then. Nice work!
     
    luispedrofonseca likes this.
  43. relser99

    relser99

    Joined:
    Jul 10, 2013
    Posts:
    4
    Hi @luispedrofonseca! I love ProCamera2D, and I admire your dedication to supporting your customers. Thank you! :)

    A question for you: what can I do to eliminate stuttering with the pixel perfect exension enabled? Enabling "Snap Camera to grid" doesn't seem to have an effect. Dropping follow smoothness to 0 gets me close, but it still stutters noticeably. I really want to use Forward Focus in addition, but that just makes the stuttering even worse.

    I'm using Transform.Translate() to move my target (actually its parent), do I need to make my translation pixel-perfect or should the "Snap Movement to Grid" option be sufficient?
     
    luispedrofonseca likes this.
  44. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @relser99 You shouldn't need to worry about making your translation pixel-perfect. ProCamera2D should handle that for you without any stuttering. Can you send me a small sample project that replicates the issue?
     
    relser99 likes this.
  45. SunnyLax

    SunnyLax

    Joined:
    Feb 9, 2017
    Posts:
    5
    Hi,
    In my game i would like to make 3/4 parralax layers, but in between those layers i would like to make a constant repeating texture with x speed. For example moving clouds.
    Is there something that support this kinda behavior ?
    also does the parralax plugin support different X/Y speed ?
     
  46. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
  47. SunnyLax

    SunnyLax

    Joined:
    Feb 9, 2017
    Posts:
    5
  48. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @SunnyLax Can I ask why the extension wasn't exactly what you wanted? Is there something missing you'd like to see added?
     
  49. SunnyLax

    SunnyLax

    Joined:
    Feb 9, 2017
    Posts:
    5
    a parameter which makes the repeated texture move with a certain speed in x would make the extension usefull for me, now i used the solution that was in the link i posted
     
  50. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    935
    @SunnyLax The reason that is not included is because the repeated object might not be a sprite/texture. The way it works now, it can be literally anything, so I leave those implementation details to the user.