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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    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. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    521
    I'm using Camera Window in conjunction with Forward Focus, but the camera window is adding some extra space which negates the effect of Forward Focus. is it possible to push the focus amount beyond 0.5 or for it to take the Camera Window into consideration?
     
  2. MSavioti

    MSavioti

    Joined:
    Dec 27, 2017
    Posts:
    4
    I'm a little bit confused about the behavior of the content fitter. Here's how I've setup the camera:

    image.png

    And here's how it looks like:

    image(1).png

    Why doesn't the content fitter area fit all the camera's area? My game camera is set to 640x360, which is 16:9.

    unnamed.png

    Thanks in advance.
     
  3. Pixitales

    Pixitales

    Joined:
    Oct 24, 2018
    Posts:
    225
    I tried fixing the transition fx with urp installed. Found out RenderImage() according to the api, it doesnt support urp. So i made a custom render pass and it works, but the transition fx show behind my ui. I need to look deeper into it.
     
  4. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    When the camera is doing a room transition, is there a way to know which direction it is moving in (up, down, left, or right? I'm trying to set up Mega Man style room transitions. In Mega Man, he freezes during a transition except he gets shifted to the other side of the doorway.

    When the transition starts, I stop player control of the character but I need to know which direction the character needs shifted.

    Any ideas welcome!
     
  5. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    281
    Why not just use players relative screen position? You already know when you’re transitioning to another room since you’re freezing players position. So when you freeze him check if he is on the righ edge of the screen, and if so camera is moving right. You can do the same check for the other directions. Don’t know the details of your game so not sure if this check would fail in some scenarios.
     
    brittany likes this.
  6. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    Thank you JesterGameCraft, that is a great idea!!
     
  7. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    I noticed what I think is a bug on the Rooms extension. When the scene starts up it starts with Finished Room Transition and ends with Started Room Transition. This makes some things not work correctly that you might start in Started Room Transition that you end when Finished Room Transition is called because they seem to be called in reverse order so you start something and it never finishes. It works fine after that initial room.
     
  8. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    Very sorry for the late reply but I haven't been getting notifications from the forum.
    The CameraWindow and the ForwardFocus extensions don't work well together since they're both trying adjusting the camera based on the player current and previous position. Do you have an example of what you're trying to achieve?
     
  9. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    Very sorry for the late reply but I haven't been getting notifications from the forum.
    Hmmm... Not sure about that. Have you tried the included demo scene to see if you're getting correct results there?
     
  10. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    Very sorry for the late reply but I haven't been getting notifications from the forum.
    Not sure I understand the issue. Can you please share a video of the issue?
     
  11. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    You can see it in the Rooms demo scene that is in Examples/Platformer/Scenes/Rooms. Press play then look at the logs in the console. First you see "Finished Room Transition - CurrentRoom:0 - Previous Room:-1", then after that you see "Started Room Transition - Current Room:0 - Previous Room:0".

    After this first room, they appear correctly with the "Started.." first and then "Finished.." afterwards.
     
    Last edited: Jul 21, 2021
  12. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    Did you see what I was talking about there?
     
  13. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @brittany Not yet, but I'll try to address it for next release.
     
    brittany likes this.
  14. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    Thanks!
     
    luispedrofonseca likes this.
  15. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    Does anyone have any ideas for how to make forward focus work for the direction the player is pointed and not necessarily the direction you are moving? In my game, for example, you can shoot left but be moving right (and vice versa). In this case I would want the forward focus to be towards the left, seeing what you are shooting at and not what you are backing into.
     
  16. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    brittany likes this.
  17. kurismakku

    kurismakku

    Joined:
    Sep 18, 2013
    Posts:
    66
    Hi there, how can I zoom in/out on my target while using ContentFitter and Number Boundaries at the same time? Camera.Zoom doesn't do anything even if it changes Camera.Size. If I change the Camera.Size through the Editor directly, it works, but not the other way around.
     
  18. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @kurismakku Since those extensions are overriding the camera size, you can't zoom in/out while they're active. You'll need to deactivate them, do the zoom and then reactivate them again. Let me know if that works for you.
     
    kurismakku likes this.
  19. brittany

    brittany

    Joined:
    Feb 26, 2013
    Posts:
    93
    2.8.2:
    - Rooms - Fixed the transition events being incorrectly ordered on start

    Thanks Luis! :)
     
    luispedrofonseca likes this.
  20. kurismakku

    kurismakku

    Joined:
    Sep 18, 2013
    Posts:
    66
    Hi there,

    I'm having an issue in a 2d shooter game where when using camera zoom, the aim angle is not correct.

    float targetAngle = Math.AngleTo(Game.current.cameraPro.GameCamera.WorldToScreenPoint(transform.position), (Input.mousePosition))

    I change the zoom using this piece of code:
    cameraPro.UpdateScreenSize(540f * (1f / Game.scale));

    If set to 540f with Game.scale = 1, it all works perfectly, the issue is when the Game.scale is changed.

    I hope you can help me with this issue.

    Thank you so much in advance and keep up the great work!
     
  21. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @kurismakku Adjusting the camera size shouldn't impact your aiming code. If that's the case my recommendation is for you to take another approach. All the `UpdateScreenSize` method does is adjusting the camera orthographic value.
     
  22. kurismakku

    kurismakku

    Joined:
    Sep 18, 2013
    Posts:
    66
    Thanks for the quick response @luispedrofonseca ! That's correct, there was a piece of code from the previous developer that was causing some issues with the camera. Once I removed it, it all works smoothly now!
     
    luispedrofonseca likes this.
  23. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    662
    @luispedrofonseca Hope all is going well!

    I was having trouble with Unity 2020 locking up (beach balling) when saving scenes or quitting the application. I traced it back to the RenderPipelineDefines script in ProCamera2D.

    Code (CSharp):
    1.  
    2. if (request == null)
    3.     return;
    4.  
    5. // Wait for request to complete
    6. while (request.Result == null)
    7. {
    8.     Task.Delay(1).Wait();
    9. }
    10.  
    This was causing an infinite loop - I think possibly because the result of the request can be null if the request fails?

    https://docs.unity3d.com/2017.4/Doc...PackageManager.Requests.Request_1.Result.html

    I've commented out the content of that class since we are still using the default pipeline, and so far that seems to have fixed the problem. Thought I should let you know.
     
    luispedrofonseca likes this.
  24. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @flashframe Thanks for reporting that. It's weird because that's been there for a while and I haven't had any reports of the same issue. I'll look into it and get back to you ASAP.
    Can you please make sure you're on the latest version (2.8.2)?
     
  25. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    662
    On version 2.8.2.

    Yeah, it could be something specific to do with my project, Unity version (2020.3.22f1), Mac OS (Big Sur) - not sure. Using Unity is always a tightrope walk!
     
  26. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    281



    Hi,

    I'm running into a problem and I don't understand why. I have Pro Camera 2D installed (to the latest) running on Unity 2020.3.21. In one of my scenes it behaves as I would expect in another it does not and no matter what settings I try it just seems to work incorrectly. I have Zoom To Fit, Numeric Boundaries and Limit Distance enabled. Although toggling these settings on/off does not seem to make any difference in the issue I'm seeing. In the proper behaviour when I move the camera close and far from the targets the camera plane stays at the same location in the bad scenario if moves all over the place. I have same targets in both scenes and same settings, including the plane setting. In the "bad" scene some of the distances and scales are changed on some of the objects. I attached a video and was wondering if you might have an idea what could be causing this.
     
  27. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    281
    Update: I think I figured it out. The XY plane I just assumed that it's Z anchor coordinate is initialized at start to wherever the targets are but it would appear that it's anchored at Z=0 coordinate. Is this right?
     
  28. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @JesterGameCraft I'm not sure I understand the issue you're having. If you're getting a problem in one scene and not the other there has to be something wrong with the setup.
    Also, you can confirm if a feature is working correctly by looking at the included test scenes.
    Let me know if you need further help.
     
  29. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    281
    Thanks for getting back. I think it does have to do with setup and I'm not sure if it's mentioned in the documentation or not, but perhaps it should be.

    You can replicate what I saw by doing the following:
    - In the example scene ZoomToFit disable input scripts on the Player and Bot so they don't move.
    - Grab Level, Player and PlayerBot and move them in positive Z axis to say +10.
    - Now move the camera to say Z +2 and check the Compensate For Camera Position in the Zoom To Fit.
    - Play the scene and pause it.
    - You can now move the camera on the Z axis back and forth and observe the zoom in/out behaviour.
    - Also changing the Zoom Amount settings and Borders is all messed up.

    Pretty sure this is not a correct setup. I think that Pro Camera 2D requires that camera is always in the Z negative space (which is fine) but this tripped me up. If it's already in the documentation somewhere great, but just wanted to let you know that if it's not it might be a good idea to add it. Or perhaps it's just implied and I'm the only person that had a problem with this.
     
    Last edited: Dec 1, 2021
  30. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    281
    I'm seeing the same thing. I reverted to older version of the ProCam and the issue went away. So it's definitely causing it. I even tried it on an empty scene in 2020.3.23. The problem is that this issue does not always happen. Here is how I was able to reliably reproduce it. I know I'm talking about scriptable objects below which have nothing to do with ProCamera2D but I was able to reproduce this issue with this technique very reliably.

    - Get an empty scene in 2020.3.23.
    - Import ProCamera2D, you don't even need to use ProCamera2D or use any of it's example scenes. Just stay on the default empty scene.
    - In Activity Monitor you will initially see a single Unity process spawned by Unity Hub.
    - Create several scriptable objects and click on them in Editor to examine them.
    - Clicking on the scriptable objects will most of the time cause another Unity process to be spawned, this time by initial Unity process and not Unity Hub. I think clicking on the scriptable objects causes Unity to spawn a helper process that does importing of scriptable objects, but I'm not sure. The key is to have two Unity processes to show in the Activity Monitor. When you have two Unity processes you'll be able to reproduce the issue.
    - Then I play the scene and edit some of the values in the scriptable objects. Then stop playing the scene.
    - At this point you will see one of the Unity processes (the one spawned by Unity process not the Hub) go into a tailspin like 117% CPU, and stay like that. If it doesn't happen try playing the scene and editing scriptable object values again. This usually works 100% of the time.
    - At this point if you try to save you'll get a frozen Unity Editor. The only way to get out of it is to kill the 117% CPU process, then Unity comes back.
    - Now remove ProCamera2D from the project and repeat the process, you'll see both Unity processes jump around in CPU usage but they stabilize and saving works just fine.

    flashframe: Can I ask how were you able to identify where the offending code was? I looked at different Editor logs and was not able to see it. I'm very interested how you found the offending code. Did you debug Editor in Visual Studio?
     
    Last edited: Dec 2, 2021
  31. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    662
    Yes - it took me a while to work out, but so helpful.

    In visual studio select Run > Attach To Process and choose Unity Editor. When Unity locks up, click the pause icon in visual studio. Then you'll be able to step through the threads and call stack.
     
    JesterGameCraft likes this.
  32. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    281
    Thank You Sir.
     
    flashframe likes this.
  33. kapopixel

    kapopixel

    Joined:
    Apr 2, 2017
    Posts:
    54
    Hello @luispedrofonseca ! Since finally camera stacking is supported on URP now, any plans for supporting parallax on URP soon?
     
  34. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
  35. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @kapopixel Yes, I've started implementation but as with everything SRP related, it's a lot more complex than the built-in variant. I'll need more time but hopefully will be ready for next release.

    [EDIT]
    @kapopixel Sorry for the confusion, I thought you were asking about the TransitionFX support for URP. The Parallax extension already supports URP since version 2.8.0. Are you having trouble with it?
     
    Last edited: Dec 4, 2021
  36. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @flashframe @JesterGameCraft Can you please contact me directly so I can send you a potential fix for the locking issue discussed above?
     
    JesterGameCraft and flashframe like this.
  37. kurismakku

    kurismakku

    Joined:
    Sep 18, 2013
    Posts:
    66
    How to limit the maximum camera shake? Every time an enemy is destroyed, ProCamera2DShake.Instance.Shake("SmallExplosion") is called, but when there are many enemies, it becomes too intensive. Yet, I want that destroying a single enemy is noticeable too so I cannot just reduce the value. Thanks in advance!

    Maybe it's related to combining shakes together, some shakes have more smoothness, and some have less, but the smoothness seems to be set to the last one?
     
    Last edited: Dec 15, 2021
  38. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @kurismakku Have you tried the "StopShaking" method? Might work if you call it before every new shake. Give it a try and let me know how it goes.
     
    kurismakku likes this.
  39. kurismakku

    kurismakku

    Joined:
    Sep 18, 2013
    Posts:
    66
    Thank you for the swift response!

    StopShaking works great for this problem.

    There is an issue though. It also stops other types of shakes that are really important in some situations. If we could call StopShaking(type of shake), that would be perfect.

    Also, it would be better if there is a difference between destroying a single enemy or multiple enemies. It's just when there are too many enemies destroyed, the shaking shouldn't be so much. So capping the shaking strength per shake type seems like a good solution.

    Any other suggestions?
     
  40. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @kurismakku There's currently no way to stop shakes based on their type - I can look into adding this option. In the meantime as an alternative my recommendation is for you to handle it on your side by keeping track of how many times shake was called in the last couple of seconds and limit it that way. Let me know if that helps.
     
    kurismakku likes this.
  41. seimusinho

    seimusinho

    Joined:
    Apr 2, 2019
    Posts:
    3
    Hi!!

    Parallax extension works with pixel perfect?

    Thanks!!
     
  42. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @seimusinho Yes, it should work. Are you having any troubles with it?
     
    seimusinho likes this.
  43. mk7gwc

    mk7gwc

    Joined:
    Mar 3, 2016
    Posts:
    27
    Hello, I have a question.
    I am unable to use the Parallax feature of Procamera2D because other assets I am currently using consume a lot of Unity layers.
    Is it possible to make the Parallax feature work without relying on layers?
    I know it is impossible, but do you have any suggestions?
     
  44. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @mk7gwc Pro Camera 2D's parallax system relies on the Unity layers to control the rendering. There may be other parallax solutions on the asset store that may not rely on them and they'd probably work fine with ProCamera2D.
     
  45. codebread

    codebread

    Joined:
    Apr 18, 2013
    Posts:
    5
    Heyo.

    I'm trying to get the Rooms extension to work on a generated dungeon. Every room of the dungeon has a ProCamera2DRoom script on it. It's doing this thing where going back and forth between the same 2 rooms only works every other attempt. Here's the order of events:

    - The camera starts in a separate scene and the player changes scenes to the dungeon
    - Room 0 works fine on dungeon scene start.
    - Player moves to the edge of Room 0 and presses a key to transition to the next room. This sets the game timescale to 0, teleports the player to the next area, calls "ProCamera2D.Instance.CenterOnTargets()", then sets the game timescale to 1.
    - Room 1 works fine and the camera is within the room bounds. Player goes BACK to room 0 and the above happens again, but the camera is still focused and locked into Room 1.
    I did a bit of debugging and noticed that the InternalID of all rooms is 0 because the rooms don't exist on the same object. There's also some wonkiness where the _currentRoomID seems to not be getting set correctly, but that also might have to do with the fact that the rooms array is a length of 1, on a bunch of different objects.

    The thing is, I tried setting all of the rooms on the ProCamera2D object just for testing and the behavior is the same. (I should note that this is done programmatically AFTER the game has started using AddRoom(), so the InternalIDs are all 0 due to that being done in the Rooms extension's Start() method.)

    All that being said, I guess my question is: What is the correct way to have a bunch of rooms set up after the game has already started, and what is the best way to move the camera to those rooms?

    I'm on version 2.7.1
     
  46. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @codebread The best way to setup multiple rooms is to have them all under the same Rooms extension. Having multiple ProCamera2DRooms extensions might cause some issues like the ones you're seeing. Can I ask why do you prefer it this way?
    Also, please make sure to update to the latest version (2.9.0) because I've made a few Rooms updates recently.
     
  47. codebread

    codebread

    Joined:
    Apr 18, 2013
    Posts:
    5
    It was easier for me to add a Room to each "tile" in the dungeon that encompasses that tile. I did do a thing where on dungeon generation I looped through every tile and removed the Rooms script on them, after calling AddRoom() on the singular Rooms extension attached to the camera. The result was the same. Right before I called it a day I noticed that maybe it's because Start() has already been called for the Rooms extension, so the InternalIDs aren't being set? (I did confirm that all Internal IDs are 0 for them, even those the list of Rooms on the script was 20ish)

    Edit: And yeah, I'll update. I checked the changelogs and didn't see much with Rooms so I hadn't tried that yet.
     
  48. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    916
    @codebread Let me know how it goes after the update
     
  49. seimusinho

    seimusinho

    Joined:
    Apr 2, 2019
    Posts:
    3
    It works perfectly. Thank you.
     
  50. hoyoyo80

    hoyoyo80

    Joined:
    Jan 31, 2018
    Posts:
    54
    Hi. Been using for a while and this is a must for a 2d games. I have a question on how to adjust zposition of the camera that targeting the object. I adjust my fov to a smaller size like 25, but i would love to position the camera a bit closer to my target thru-out the game. Thanks