Search Unity

Master Camera: Scroll/Zoom, Strafe, FPS-3PS Toggling, Minimal/No Clipping and More

Discussion in 'Assets and Asset Store' started by tzvier, Dec 8, 2011.

  1. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Great Greg! Glad to hear that it all worked out. Let me know if you run into any more trouble.
     
  2. ShinyTaco

    ShinyTaco

    Joined:
    Sep 4, 2012
    Posts:
    70
    Hey there, great asset!

    I was wondering if you could help a bit? Basically I need the rig to rotate 90 degrees, to directly above the player when something happens.

    How would I go about doing this?

    Thanks!
     
  3. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Hey, thanks for the purchase!

    What you'll want to adjust is the MC.RotationPoint. I would go to something like 89.5 degrees to avoid gimbal lock.

    Let me know if that helps out.
     
  4. ShinyTaco

    ShinyTaco

    Joined:
    Sep 4, 2012
    Posts:
    70
    Thanks for the reply.

    I need the rig to switch back and forth from behind view to the above view, 89.5.
    I've been trying to do this with Quaternion.Slerp (from.rotation, to.rotation, Time.time * speed);
    with the script attached to MC.RotationPoint.

    Is this the right way to go about it?

    I can't get the rig to rotate. Any help is really appreciated.

    Thanks.
     
  5. ShinyTaco

    ShinyTaco

    Joined:
    Sep 4, 2012
    Posts:
    70
    Hey, every things working pretty good so far.

    However, when I walk backwards and have Enable Camera Collision ticked, the camera jump to my player when I walk backwards. If I untick it, it works fine.

    Any ideas on how to fix this?

    Thanks.
     
  6. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Make sure that your CharacterController and any player colliders are on a layer that is not tested for collisions.
     
  7. ShinyTaco

    ShinyTaco

    Joined:
    Sep 4, 2012
    Posts:
    70
    Yeah that worked, thank you.
     
  8. ShinyTaco

    ShinyTaco

    Joined:
    Sep 4, 2012
    Posts:
    70
    Hey again,

    I was wondering how you would go about switch camera targets at runtime? I have an if statement in the FixedUpdate function, it' get's called, but it doesn't work. The camera still follows the original target.

    Any help is really appreciated.

    Thanks again.
     
  9. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    It should work if you change the "Player" variable of the MasterCamera script.
     
  10. ShinyTaco

    ShinyTaco

    Joined:
    Sep 4, 2012
    Posts:
    70
    Yeah, I tried that, it doesn't work. It still follows the original Player.
     
  11. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Can you try changing the MasterCamera.js "Player" object to another object in the editor while in play mode? Does the camera move to track the other object then?
     
  12. levan1

    levan1

    Joined:
    Nov 16, 2013
    Posts:
    14
    is it possible to use this camera in a car game?
     
  13. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
  14. DougMcFarlane

    DougMcFarlane

    Joined:
    Apr 25, 2009
    Posts:
    197
    Loving this camera asset!

    In 'CameraRotation.FollowBehind' mode, how do you recommend (in a script) initialing the camera position and rotation, relative to a player? I see a 'MC.LocationAdjustment' component, but that isn't quite what I want.
    I have a player game object (empty for now), and this is specified in 'Player' setting of your camera control.
    But I want the camera positioned a half a world unit back, and a half a world unit above, and rotated downwards 30 degrees towards the player (numbers are just an example).

    Here's how I'm doing it now, and it works generally:
    Code (csharp):
    1. MasterCamera.cam.transform.position = player.transform.position + new Vector3(0.0f, 0.5f, -0.5f);
    2. MasterCamera.cam.transform.rotation = player.transform.rotation * Quaternion.Euler(30,0,0);

    But then when the player hits the left mouse button, I want to switch to mouse look using the CameraRotation.MouseHorizontalAndVertical mode. This kinda works, but is messy. It starts out fine, but each adjustment gets more off. How do I limit the camera to +/- 45 degrees in the y direction. I don't understand the min / max angle vertical settings, and things go wacky.

    Then when the player releases the button, go back to 'FollowBehind' mode, and reposition the camera back (smoothy interporlated over time - which is does, but goes to the wrong position) to the original position and rotation.

    I've tried this (in LateUpdate()):
    Code (csharp):
    1. if (Input.GetMouseButton(0)) {
    2.     MasterCamera.cameraRotationMode = CameraRotation.MouseHorizontalAndVertical;
    3. }
    4. else {
    5.     SetCameraRotation(Quaternion.Euler(35,0,0));
    6.     SetCameraPosition(new Vector3(0.0f, 0.6f, -0.5f));
    7.     MasterCamera.cameraRotationMode = CameraRotation.FollowBehind;
    8. }
    9.  
    10. public static void SetCameraPosition(Vector3 position) {
    11.     MasterCamera.cam.transform.position = PlayerManager.player.transform.position + position;
    12. }
    13.  
    14. public static void SetCameraRotation(Quaternion rotation) {
    15.     MasterCamera.cam.transform.rotation = PlayerManager.player.transform.rotation * rotation;
    16. }

    Why do I (or at least appear to) need to reference the player transform again, I thought it was connected to the camera already? It would be nice if you offered a default offset and rotation for the follow behind mode. Or there is and I don't know how to do it!

    Thanks for any help.

    [Edit] Off topic, how to you display code in these posts? I see the bb editor, but no options. Do I just have to know the proper codes to type? I swear this is new, and I posted code before, but not sure!
    [Edit2] Got it. use [ CODE ][ /CODE ]
     
    Last edited: Jul 10, 2014
  15. DougMcFarlane

    DougMcFarlane

    Joined:
    Apr 25, 2009
    Posts:
    197
    The question above got very confusing by the time I finished writing it.

    Simply, how to I have a FollowBehind mode normally, except while the player is clicking a mouse button (for example), which now the camera goes into MouseHorizontalAndVertical mode until he releases the button, then back to FollowBehind mode (smoothly resuming the camera to the oringal position/rotation). (Did an earlier version offer this?)

    And where do I set the actual camera offset / rotation relative to the player? I want the camera a bit above and behind, and tilted downwards 30deg towards him.

    While in MouseHorizontalAndVertical mode, I want to limit looking to +/- 45° up and down, but full 360° left/right.

    Thanks.

    [Edit] Is there any official documentation for Master Camera? I couldn't find any on the site.
     
    Last edited: Jul 10, 2014
  16. DougMcFarlane

    DougMcFarlane

    Joined:
    Apr 25, 2009
    Posts:
    197
    Is there ANY documentation on the various methods and properties of MasterCamera? I've been trying to figure out my questions, but I'm having no luck.

    I've tried this, but it doesn't work:
    Code (csharp):
    1. MasterCamera.locationAdjustment.transform.position = new Vector3(0.0f, 0.6f, -0.5f);
    ;
     
  17. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Hi Doug,

    I apologize for the late reply here. It sounds like you want to start out with FollowBehind mode, with the Vertical > Min & Max Angles set to 30, and the Preferred distance set to 0.5.

    Preferred distance is the distance the camera is from the player.

    Then it sounds like you want to add a MCButtonLook script to the rig. Change the Button Vertical > Min Angle to -45 and the Button Vertical Max Angle to 45.

    This will get you what I think you're looking for.
     
  18. levan1

    levan1

    Joined:
    Nov 16, 2013
    Posts:
    14
    Hello,
    I've purchased your asset and really like it. But is it possible to work 2 cameras in the game? for instance: 1. follod behind and 2. mousehorizontalandvertical
    Is it clrear? I want to have 2 cameras in the game and the gamer have to option to switch from one camera to the other.
     
  19. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Hi levan,

    I don't see any reason that you couldn't set up two cameras. However it sounds like it might be a better option to dynamically switch the follow mode through some trigger at run time.
     
  20. peter_rodrigues

    peter_rodrigues

    Joined:
    Jan 28, 2014
    Posts:
    39
    Hello, I was wondering if there was a way to have to camera default to the strafed camera at start. For my game I love how the camera looks when I strafe it to the left but I want it to start out that way instead of having the player actually press a button to position it that way.

    I hope I explained that correctly.
     
  21. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Hi Peter,

    In the MCStrafe's Awake function on line 25 it should say

    Code (CSharp):
    1.     strafeLocation = 0;
    You can change the 0 to whatever you'd like, or turn it into a variable. I have just submitted a new version that ads a StartLocation variable to set the initial position based on your suggestion. Thanks for the feedback!
     
  22. peter_rodrigues

    peter_rodrigues

    Joined:
    Jan 28, 2014
    Posts:
    39
    Awesome. Thanks!!
     
  23. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    i'm interested, but can you add option to your camera / demo where the character turns left, right was mouse moves left and right with the camera following and looks up and down as the camera follows

    thanks in advance!
     
  24. Melo82

    Melo82

    Joined:
    Aug 1, 2013
    Posts:
    3
    Hi, When I use to maintain FollowBehind (S or down) the key player stays spinning like I evirar that? And when I move it forward slowly rotates.

    As wn FollowBehind I set the camera mode without jumping. I walk through a door and the camera is set to jump like crazy using the MCScroll way, anyone know the optimal settings?
     
    Last edited: Oct 1, 2014
  25. Garbagelight

    Garbagelight

    Joined:
    Sep 30, 2014
    Posts:
    1
    Hey

    So everything works fine in the demo included, but for some reason, when I throw it onto a character in another scene the camera automatically starts from an arial view of the player. Not sure what is going wrong, I have tried messing with layers and such and am just confused.

    Whenever you get a chance your help would be greatly appreciated!

    thanks
     
  26. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    im,

    I'm not sure what you're looking for exactly. It sounds like you're looking for Follow Mode with MCButtonLook set to trigger on Fire2.


    Melo82,

    With FollowBehind, S would cause a spin as the camera is trying to move to behind the player. For the twitchy door situation, it sounds like you may need to adjust the MC.Collider Objects to accommodate a narrow door way. Take a look here:



    Garbagelight,

    It sounds like the initial camera rig location is far away from your character. Simply move the rig to your character's starting location. I generally just make the rig a child of the character, 0 out the position and rotation, and remove the rig from the character.
     
  27. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Just imported MasterCamera into my project and getting many errors:
    Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js(325,33): BCE0048: Type 'Object' does not support slicing.
    Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js(327,44): BCE0019: 'CrossFade' is not a member of 'Object'.
    Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js(350,41): BCE0048: Type 'Object' does not support slicing.
    Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonCamera.js(141,9): BCE0005: Unknown identifier: 'currentHeight'.
    Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonCamera.js(145,9): BCE0005: Unknown identifier: 'currentRotation'.
     
  28. Melo82

    Melo82

    Joined:
    Aug 1, 2013
    Posts:
    3
    [Quote = "Rocki, publicar: 1797026, miembro: 123505"] Justo importados MasterCamera en mi proyecto y conseguir muchos errores:
    Activo / Activo estándar / Controladores de caracteres / Fuentes / scripts / ThirdPersonController.js (325,33): BCE0048: Tipo 'Object' no admite el corte.
    Activo / Activo estándar / Controladores de caracteres / Fuentes / scripts / ThirdPersonController.js (327,44): BCE0019: 'CrossFade' no es un miembro del 'objeto'.
    Activo / Activo estándar / Controladores de caracteres / Fuentes / scripts / ThirdPersonController.js (350,41): BCE0048: Tipo 'Object' no admite el corte.
    Activo / Activo estándar / Controladores de caracteres / Fuentes / scripts / ThirdPersonCamera.js (141,9): BCE0005: Desconocido Identificador: 'currentHeight'.
    Activo / Activo estándar / Controladores de caracteres / Fuentes / scripts / ThirdPersonCamera.js (145,9): BCE0005: Desconocido Identificador: 'currentRotation' [/ quote].

    Reloads the Character Controllers in Unity and you fix it.
     
  29. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Thanks, reimporting the unity character controller package fixed the problem.
    Don't know why MC doesn't already have this already setup properly to save the extra headache.
     
  30. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    sounds about right, Follow Mode with MCButtonLook set to trigger on Fire2.
     
  31. mvesich

    mvesich

    Joined:
    Jan 5, 2013
    Posts:
    5
    Hey tzvier,
    First, love your product! It's been a breeze to implement both the JS & C# versions. Can't tell you how much time you've saved me.

    In my current app needed to be able to reset the camera angles at the touch of a button, so I was able to leverage SetHorizontalRotation & SetVerticalRotation. However, I was missing a method to handle the distance as I have MCScroll enabled on the camera. I added the following the the MasterCamera script, which seems to work. I was hoping that you could give this method your nod of approval and if I might ask, include it or your own public method in the next update to support the setting of the value. It'd be a real value to be able to control the position and zoom from script.

    Code (CSharp):
    1.     public void SetPreferredDistance(float distance){
    2.         preferredDistance = distance;
    3.     }
    Thanks!
     
  32. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Hi mvesich,

    That looks good and thanks for the suggestion! If I get enough to do another update, I intend to add it. :)
     
  33. airblaster

    airblaster

    Joined:
    Oct 5, 2014
    Posts:
    8
    Is it possible to integrate MasterCamera with a Mecanim Character Controller, like e.g. the Motion Controller Asset by ootii?
    If so, how would you approach it?
     
  34. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    I'm not sure what ootii is, but yes, the set-up should be the same. The camera rig simple follows whatever is put as the 'Player' variable.
     
  35. airblaster

    airblaster

    Joined:
    Oct 5, 2014
    Posts:
    8
    Thanks, MasterCamera works well with bolt after some slight modifications.
    In case anyone is interested, I've posted an HowTo in the bolt forums.
     
  36. Tanoshimi2000

    Tanoshimi2000

    Joined:
    Feb 10, 2014
    Posts:
    46
    I certainly hope I'm doing something incorrect, because I am not having good results.
    - I have added the MasterCameraRigC# prefab to my level.
    - Set Camera Rotation Mode to Follow Behind
    - Set the layer to Everything, Nothing, Default, and every combination I can try.
    - Set the sensitivity low and high.

    What I get is the camera still goes through walls so I can't see my player, and it goes through other characters as well.
    I've gone through the video tutorials step by step. The only differences between mine and your videos is:
    1) I don't use the Third Person Controller, I use a controller I've already been using that came with my characters
    2) my characters are Instantiated at runtime, so they're not part of any layer.

    Knowing #2 might be an issue, I've added them to the default layer at runtime, but I still get no collision. To be honest, I was having better results when I put my camera in a box and added a box collider.

    I'm really hoping I can get this to work. If you want to see what I'm getting, feel free to play it at www.DCJoys.com/games/MM/MM.html

    All sugestions are welcome.
     
    Last edited: Dec 24, 2014
  37. levan1

    levan1

    Joined:
    Nov 16, 2013
    Posts:
    14
    Hey tzvier,
    i have this scirpt to pause the game:
    Code (JavaScript):
    1. var pause : boolean = false;
    2. var pauseGUI : GUITexture;
    3. pauseGUI.enabled = false;
    4.  
    5. function Update(){
    6. if(Input.GetKeyUp(KeyCode.P)) {
    7. if(pause==true){
    8. pause = false;
    9. }
    10. else {
    11. pause = true;
    12. } if(pause == true) {
    13. Time.timeScale = 0.0;
    14. pauseGUI.enabled = true;
    15. }
    16. else {
    17. Time.timeScale = 1.0;
    18. pauseGUI.enabled = false;
    19. }
    20. }
    21. }

    when i pause game, this error happens
     
    Last edited: Dec 26, 2014
  38. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Tanoshimi,

    You'll need to attach the MCScroll script to your MasterCamera rig to control the camera scrolling when a collision is detected.

    levan,

    I'm not sure what would cause that error. I suppose setting the timeScale to 0 is confusing some interpolation. I would try setting the follow mode to none before setting timeScale to 0, and setting the follow mode back after setting timeScale back to 1.
     
  39. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Any chance this will include mobile camera controls examples?

    Like pinch an area to zoom, drag to rotate?

    Might be awesome!
     
  40. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    I can say that it will work on mobile with some additional work. I had it set-up to function on Android a while ago as a test. Unfortunately though I'm not sure I can commit the time to create release worthy addons for mobile in the near future.
     
  41. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    It will be very valuable, since the huge amount of mobile devs nowadays.

    I hope you do release a guide on how to use master camera to mobiles!
     
  42. Tanoshimi2000

    Tanoshimi2000

    Joined:
    Feb 10, 2014
    Posts:
    46
    I could use some guidance on the settings. I believe part of the problem is that my game takes place inside and so the camera has to scroll or zoom based upon the ceiling and the props and the characters.

    I added the MCScroll script, and I think it's working, but I get weird camera changes like at some points I'm zoomed far away from my character, and and the very next instant all I can see are his boots.

    Not sure if my scale is different than what the camera is expecting or I just don't know the settings, but it's jumping from further away than the master settings, to way too close to be useful.

    I'll continue to play with it, but some guidance or a manual or a tutorial on the new system would be appreciated.
     
    Last edited: Dec 31, 2014
  43. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Tanoshimi,

    You may find the information that you need in this tutorial video:

     
  44. Tanoshimi2000

    Tanoshimi2000

    Joined:
    Feb 10, 2014
    Posts:
    46
    Thanks I certainly appreciate that. I got it working fairly well, playing with the settings, but I believe the problem is my scene may not be what it's built for. My level is an interior level, hallway with ceiling is only about 10'wide by 10' tall. with larger rooms sprouting off it. Might be too confined a space for the camera. Also, I have several team members that follow me, so the space immediately behind the player is usually taken.

    Will continue to play with settings, and review the tutorial, and thanks for getting this to me, but I'm thinking the level might be too tight. Considering putting the walls and ceiling on the level that will make them alpha. I've done that with the team mates and it's working out nicely.

    Good product. Good support.
     
  45. peter_rodrigues

    peter_rodrigues

    Joined:
    Jan 28, 2014
    Posts:
    39
    A little help would be appreciated. I have the camera strafed but once the camera collides with a wall it returns to the default "0" position. Is there any way to make the camera locked in a strafe position without reverting back to the original position set behind the character?
     
  46. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Hi Peter,

    If you want the camera to always stay over one shoulder, you can move the MC.LocationAdjustment over that shoulder and remove the MCStrafe addon. Is that what you're looking for?
     
  47. DFT-Games

    DFT-Games

    Joined:
    Jun 24, 2010
    Posts:
    454
    One thing is still missing to make this a great plug & play package: the ability to fade all the materials in each renderer. Currently it's based on the assumption that there is 1 material per renderer, but that isn't always the case ;)
     
  48. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Is this being developed anymore? One person had referred me to this, however it seems like it lacks one feature quite important for 3D platformers: Camera that orbits around character (controllable with mouse) on both axis (with amount you can rotate by on Y axis being limited). For reference, see how camera was controlled in PC ports of games like Rayman 2, Kao the Kangaroo, etc. Or at least such capability wasn't shown in webplayer demo.

    I'd also like to inquire about compatibility with Unity 5. Thank you for your cooperation.
     
  49. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    While I'm not actively developing on this, I do respond the forums here to address any issues that come up.

    It sounds like you're looking for the MasterCamera script > Camera Rotation Mode > "Mouse Horizontal And Vertical" selection.

    I haven't run into any issues with Master Camera on Unity 5. If you do run into something, please let me know and I can address it.
     
  50. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Thank you. While I don't have money to buy your script yet, can you tell me if your camera clips through the low ceilings (the solution I'm using currently does :()? Unfortunately can't put it into my own scene, as I didn't buy it yet and demo scene doesn't have any place where ceiling is barely above character to test it reliably.

    Have a nice day, by the way.

    //edit: Also does it have something like "minimum distance" so I can limit scroll zoom so it never will go right into character unless wall's in the way?