Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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
    Update 2.5.2
    -MCButtonLook now has the option to return the camera to position it was in when the button was pushed (Return To On Click : True), or stay where it is currently at. (Return To On Click : False)
     
  2. jjcuff1

    jjcuff1

    Joined:
    Mar 14, 2012
    Posts:
    8
    Simple newbie question

    1: great Product!!! Thanks I am working on a spaceship game so playing with FPS/3PS but how/where do I add skybox to the MC camera?
    I added skybox script to the MCRig and selected a skybox texture pack but it doesnt appear when I play? Also, if I switch from FPS/3rd i add the preset and add on my player and toggle but do I need BOTH FPS controller script and 3rd person controller script in the player?
     
  3. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    jjcuff1: Thanks for posting.

    Inside the Master Camera Rig is the actual camera. Open the hierarchy until you find it, and add the skybox component to it. Make sure the camera "Clear Flags" is set to "Skybox" and set your skybox material in the skybox component.



    Hope that helps.
     
  4. nab477

    nab477

    Joined:
    Jun 14, 2011
    Posts:
    46
    Hi, this seems like a handy asset that can be used in most projects.
    but, the video on youtube stops playing around 11:35, can you please see if there's an encoding problem, or put a downloadable version of it.

    anyway, the question I have for now is, can I set the camera to follow the player at the same time fade the objects between the player camera as well as the objects between the camera enemies ?
    (as I was typing the question I think I might've got the answer already, if i set the enemy layer to "Player" as well, will this work ?)

    also, this is hard to test with the scroll wheel, but if I zoom in/out using the pinch gesture on iOS android devices, will the zooming in/out be a smooth transition between the current zoom level to the new one (while keeping the player in center) ? or will it be sudden exact ?

    (I'm not going to use it with a mouse for now, but I think I should mention this as well)
    in the demo, if I choose FollowWButtonLook then move it to look somewhere, then move left or right make the camera rotate, then click anywhere, it jump back to the last position that was made while clicking (sometimes it turns 180 degrees suddenly).
    was this fixed in recent versions ? cause I think this behavior isn't acceptable, it should forget the previous state start from where the player is looking right now.

    also, just to confirm, this contains the JS code, but by putting it in the "Plugins" folder, it will be compiled before any C# code I can access it from there if I need to, right ?
     
  5. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    nab477, I assume you're talking about the video at the top of the thread? It seems to play through fine for me, maybe try viewing directly from youtube?

    The camera currently does not fade out objects between the camera and enemies. I will look into adding this functionality.

    I haven't tested it on mobile devices personally, but I believe believe scrolling in and out would still depend on the "Speed" variable in the MCScroll script.

    The button look has been updated in version 2.5.2 to either maintain it's position on button release, or snap back to the starting location.

    All the code is in JS. From what I understand based on this putting the code in the "Plugins" folder will cause it to be compiled before code that is not also in the "Plugins" folder or the "Standard Assets" or "Pro Standard Assets" folders.
     
  6. nab477

    nab477

    Joined:
    Jun 14, 2011
    Posts:
    46
    Tzvier,
    yes, I was talking about the video on the first thread, it seems to work fine now, (probably some problem at my end, even though I did try it with different browsers).

    thank you for considering the fading functionality answering the question.

    for the mobile devices, well, it'll simply be a different script that will read input adjust a variable on the camera, so to test, it can be done by making space toggle 2 different values incrementally.
    so, I guess what I meant by that is if I have a script that updates it from the user input the zoom values goes into it something like this
    (0.1, 0.3, 0.32, 0.35, 0.5) (assuming that 0 is the least value I want the zoom to reach 1 is the farthest)
    anyway, these values will be caused by the player not moving his fingers in a uniform speed, the script I'll write will (in a perfect world) send these values to the camera directly.
    so, my question is that will the camera move the zoom to these values ? or will it use the values as the target zoom use the Speed variable to reach the target smoothly ?
     
  7. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    With the MCScroll script attached to the camera rig, you could write a script that controls the "preferredDistance" variable in the MasterCamera script and it will control the camera distance.

    Code (csharp):
    1.  
    2. var mc : MasterCamera;
    3. var distance : float = 3;
    4.  
    5.  
    6. function Update () {
    7.  
    8.     mc.preferredDistance = distance;
    9.  
    10. }
    11.  
     
  8. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Update to version 2.5.3
    -MCLOSFadeOther has been added to the "MC Xtra Files" folder.
    This script can be attached to any object that should trigger Line of Sight Fading for objects on the fade layer.
    The fading will only happen if the object is in the camera's field of view.
     
  9. nab477

    nab477

    Joined:
    Jun 14, 2011
    Posts:
    46
    thanks for adding that :)

    even though I don't need the camera on my current game (static camera side view), this is a safe bet I'm sure any game with a dynamic camera will benefit from it.

    sold.
     
  10. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    Tzvier,

    With the availability of a free mobile license (until April 8th!), have you thought about grabbing that to develop a mobile version of the Rig?

    Best,
    Pat
     
  11. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    nab, Thank you for the suggestions. It's a good feature and wasn't difficult to implement.

    Pat, The rig works on mobile already and has been used in iOS and android projects. I have taken advantage of the free mobile license though so I can verify the features personally.
     
  12. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    You mean it supports touch interfaces already?
     
  13. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Unfortunately, despite now having the free mobile Unity License, I am unable to find the drivers for my Korean Android phone. I am still unable to test this personally on a mobile device.
     
  14. nab477

    nab477

    Joined:
    Jun 14, 2011
    Posts:
    46
    Tzvier,

    what are the possible reasons that could prevent an object from fading ?

    I'm trying the master camera with Tidy Tile Mapper (making a ball rolling game), but when a tile is between the ball the camera, it doesn't fade.

    I tried to change the shaders to Transparent/Diffuse, but still no success.
    (in case it matters, many objects (tiles/blocks) use the same material)

    when I try to add something from "Create Other => Cube/Sphere" they fade correctly.
     
  15. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    nab447: Assuming you've set the "Fade Layer" to be whatever layer the tiles are on, the first thing that comes to mind is that the rays are not colliding with the tiles. I'm not familiar with the inner workings of the Tidy Tile Mapper, but I am pretty sure that there are some types of colliders (e.g. character controller) that do not react to raycasts, and a sphere cast needs to be used.

    The type of material/shader shouldn't matter, the script keeps track of the materials/shaders that it fades out so it can put them back correctly.

    This may require some debugging, I will send you a PM and we see if we can figure this out.
     
  16. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    New Update 2.5.4
    -MCLOSFade and MCLOSFadeOther scripts now work with objects where the renderer is on a child object of the collider, and with colliders that have multiple child renderers.
    -MCLOSFade and MCLOSFadeOther scripts now allow defining a string for the "FadeShader" that is, the shader used when fading the object. The default is "Transparent/Diffuse"

    Thanks to nab477 for assisting in this update!
     
  17. pepefirst

    pepefirst

    Joined:
    Feb 24, 2011
    Posts:
    70
    Today I bought your Master Camera to use it on my iOS project. At the moment I switched platform (from Mac/PC to iOS) I got similar errors to a problem described previously by an Android user. Your recommendation was to substitute the line
    private var components;
    for the line
    private var components : Component[] ;

    This did not help on my case because I did not have the line: private var components;
    Some of the errors were:
    Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js(328,44): BCE0019: 'CrossFade' is not a member of 'Object'.
    Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js(327,33): 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'.

    Any help on how to fix this problem?

    Thanks!
     
  18. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Hi there pepefirst,

    Thank you for the purchase!

    These errors are with Unity's Standard Assets files "ThirdPersonCamera.js" and "ThirdPersonController.js" They don't have anything to do with the Master Camera scripts. What is needed are the mobile versions of these scripts which should be included when you build a new project with the Standard Assets (Mobile) package.

    I hope that help!
     
  19. pepefirst

    pepefirst

    Joined:
    Feb 24, 2011
    Posts:
    70
    I am confused because I am using your test scene and it includes the scripts that you mentioned: "ThirdPersonCamera.js" and "ThirdPersonController.js" . In any case I am attaching a screenshot where you can see them on the Hierarchy or on the Inspector.
     

    Attached Files:

    Last edited: May 15, 2012
  20. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Yes, the test scene contains Unity's "Standard Assets" package. To get the test scenes to work for mobile, what you need is the "Standard Assets (Mobile)" package.

    On the menu bar go to Assets > Import Package > Standard Assets (Mobile)

    Once that is set up, you'll likely have to remove the Standard Assets folder and files, and replace the 3rd Person Controller in the scene.

    Let me know if that works out.
     
  21. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Hi. I am getting the following error - "Material doesn't have a color property _Color" - on mobile shaders.
     
  22. tzvier

    tzvier

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

    Can you list out the full error?
     
  23. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063

    Sure:

    Only happens on models using a mobile shader that doesn't have a color property. Specifically Mobile Vertex Lit is the one I am using.
     
  24. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Thanks drew,

    I am looking into an acceptable fix the get color issue.
     
  25. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Thanks! In the mean time, I've set them all to vertex colored which solves the problem and is a good temporary solution.
     
  26. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Ok, new version has been submitted to the Asset Store.


    2.5.5
    -MCLOSFade and MCLOSFadeOther scripts now work with materials that have no color option such as Mobile > VertexLit.
     
  27. nilton_felicio

    nilton_felicio

    Joined:
    May 17, 2012
    Posts:
    66
    I am very interested in Master Camera.
    I wonder how the license to use and update the product?
     
  28. arcticwaffle

    arcticwaffle

    Joined:
    May 27, 2012
    Posts:
    1
    I set up my camera exactly as I was supposed to, but it does not work one the terrain in my game. I tried it on another terrain and it works fine but on the one in my game it goes right through it. Same with my objects. Do you know why this is happening. I used the 3rd person shooter preset on my camera.
     
  29. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    @nilton : If you purchase the asset, you receive all future updates and no cost.

    @arctic : The first thing that comes to mind is to make sure that your terrain is on the correct layer for camera collision.
     
  30. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Weird problem with switching platforms to Android. For some reason it changes all my Mobile Transparent Shaders to completely invisible and switches to a default transparency without fading it further so the result is the tree tops which use Mobile Transparent are gone until they are between the player and the camera when they change to Transparent Diffuse but don't actually fade so I can't see the player. This happens for any objects but it doesn't make them invisible unless it uses mobile transparent. Not getting any errors or anything, it just goes all screwy. If I switch platforms back to web player, it fixes the problem.

    edit: Upon further inspection, it doesn't seem to be a problem with master camera. Some other issue is causing this to happen. grrr.
     
    Last edited: Jun 9, 2012
  31. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    drew, If you set up a new project for android does this still happen? Does it happen when you switch to iOS?
     
  32. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I've been playing around with it and it works fine for primitives but not for skinned meshes. For example I am using some buildings and trees from two different sources and the Mobile/Transparent turns them all completely invisible. But I put a cube in there and even apply the same material, it fades properly, no matter what the setting is. As a work around I set MC up to use the mobile transparency which turns them completely invisible. And set the meshes that actually use transparency (like treetops) to a non mobile transparent. Not ideal really but better than not seeing the player.


    I haven't checked with a new project. I will try that now. But I get many errors regarding the Standard Third Person controller when I switch to Android usually just delete it since I am using my own anyway. I'll report on what happens when I try a new project that is already android.

    Don't have a mac so iOS isn't an option.


    p.s. I have not tried it on an actual android device. This is what happens in the player window. I guess I should build one out and see if it works properly on the device but not in the player window...

    edit: It seems to work fine on a new Android project. Good thing I haven't gotten very far.
     
    Last edited: Jun 9, 2012
  33. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    drew, sounds like you've got it working now?

    The example scenes that come with the camera are built for the pc/webplayer, and therefore contain the non-mobile Standard Assets. As you've seen, trying to build a mobile game off the example scenes can cause all kinds of issues. It's best to start a new project, importing the Standard Assets (mobile), and then importing the Master Camera package into that new project. Best of luck, and let me know if you run into any more issues in the future.
     
  34. billtaichi

    billtaichi

    Joined:
    May 16, 2012
    Posts:
    1
    Hey I bought Master Camera during Asset Madness and I love it.

    I do have a question though, I am new to Unity and game dev so I apologize if this should be obvious. I have a master camera that follows my 3rd person controller around, I have a second camera (plain camera not a master camera rig) I use that to follow a thrown axe (call it axe cam, time slows you watch the axe hit target). When the axe is thrown the 2nd camera becomes active, after the axe is thrown control switches back to master camera. When I set master camera to Active = false or enable = false It does deactivate BUT I am getting a bunch of errors which are coming from the master camera script (not at home right now so sorry that I can't post exact message) Once the master camera is reactivated the errors stop.

    My question is , is there a way to deactivate the master camera temporarily without throwing all the Update errors?

    Thanks for any help.
     
  35. tzvier

    tzvier

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

    That's a good question. I haven't experimented with a second camera in the scene before. When you get a chance to post the specific errors I can investigate the issue. Sounds interesting. :)
     
  36. bwheatley

    bwheatley

    Joined:
    Jun 23, 2012
    Posts:
    45
    weird bill i'm not having that trouble at all with mine. Though i'm running the RTS setup now I did start with the 3rd person setup and it was ok. I have a 2nd camera that supports the GUI for a level that you can bounce back and forth between.

    Code (csharp):
    1.     public void ToggleUI () {
    2.         //Debug.Log("We are in the ToggleUI Mode boss!");
    3.        
    4.         //we need to toggle the active camera
    5.         if ( gamecamera.active == true ) {
    6.             uicamera.active = true;
    7.             gamecamera.active = false;
    8.             //Debug.Log("UI CAM ACTIVE NOW");
    9.         }
    10.         else {
    11.             gamecamera.active = true;
    12.             uicamera.active = false;
    13.             //Debug.Log("GAME CAM ACTIVE NOW");
    14.         }
    15.            
    16.     }
     
  37. bwheatley

    bwheatley

    Joined:
    Jun 23, 2012
    Posts:
    45
    Tzvier is there an easy way even with RTS mode to have you able to rotate the cam? I turned mcbuttonlook on but the view returns when you let go of the mouse. I can tweak it to make sure the camera stays rotated after i let the button go but i didn't know if i missed something easy.
     
  38. bwheatley

    bwheatley

    Joined:
    Jun 23, 2012
    Posts:
    45
    I wrote this RotateCamera script that you can attach to the Master rig

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. //Requirements
    6. //[RequireComponent(typeof(MasterCamera))]  //When we finally rewrite master camera in C# we can use this
    7.  
    8. public class rotatecamera : MonoBehaviour {
    9.    
    10.     public GameObject MasterCamera;
    11.     public string RotateLeftKey = "q";
    12.     public string RotateRightKey = "e";    
    13.  
    14.     //Cache the component for the first look
    15.     void Awake() {
    16.  
    17.     }
    18.    
    19.    
    20.     // Use this for initialization
    21.     void Start () {
    22.    
    23.     }
    24.    
    25.     // Update is called once per frame
    26.     void Update () {
    27.        
    28.         //If LeftKey is pressed call RotateCameraLeft
    29.         if (Input.GetKeyDown(RotateLeftKey)) {
    30.             RotateCameraLeft();        
    31.         }  
    32.         //If RightKey is pressed call RotateCameraRight
    33.         if (Input.GetKeyDown(RotateRightKey)) {
    34.             RotateCameraRight();
    35.         }      
    36.     }
    37.    
    38.     void RotateCameraLeft () {
    39.         PrintYAngle();
    40.         MasterCamera.transform.Rotate(0,90,0);
    41.         PrintYAngle();
    42.        
    43.        
    44.     }
    45.    
    46.     void RotateCameraRight () {
    47.         PrintYAngle();
    48.         MasterCamera.transform.Rotate(0,-90,0);
    49.         PrintYAngle();
    50.     }
    51.  
    52.     void PrintYAngle () {
    53.         Debug.Log("Y Angle "+ MasterCamera.transform.eulerAngles.y);       
    54.     }
    55. }
    56.  
     
  39. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    @ bwheatley, There is a boolean option in the MCButtonLook script called "Return to On Click" if you disable that, you can look around with the mouse and the camera will not snap back to it's original rotation. Is that what you were looking for?
     
  40. bwheatley

    bwheatley

    Joined:
    Jun 23, 2012
    Posts:
    45
    No because i'm using the RTS cam so when i tried that it ended up making the camera not work right. Needed to keep the same perspective. So i wrote that script it works alright. Next i was thinking of doing (unless you're already doing it) is making the camera pan in as you zoom in from RTS mode. When you start from far out and zoom in close it would be cool to have it pan to give you a better perspective.
     
  41. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    You can constrict the angles the mouse can rotate through using the MCButtonLook > Button Vertical > Minimum / Maximum Angle. If you set the minimum and maximum angles to say 60, as is the default angle for camera in RTS mode. It will not let you rotate the camera up and down, only left and right. Like such:


    By pan, I assume you mean rotate the camera itself upward slightly as the camera zooms in? That's a feature I can add pretty easily.
     
  42. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    Update 2.5.6

    -Updated MCScroll to be able to turn on and off MeshHiding, as well as Camera Collision, both are now off by default.

    -Added MCZoomPan which allows for the camera to pan a certain direction as the camera zooms / scrolls in or out.
     
  43. bwheatley

    bwheatley

    Joined:
    Jun 23, 2012
    Posts:
    45
    nice thanks!
     
  44. bwheatley

    bwheatley

    Joined:
    Jun 23, 2012
    Posts:
    45
    Works like a charm (zoompan) thanks a lot for doing that for me <3
     
  45. bwheatley

    bwheatley

    Joined:
    Jun 23, 2012
    Posts:
    45
    All the videos are off the thought vandel site is that right? I was trying to find some clarification on the Mesh hiding object. Mostly where to find one :)
     
  46. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    The MCScroll > Mesh Hiding > Mesh Object is an object that contains character meshes, or any parent of that object. For example:



    The Bip001 Pelvis is where the actual character mesh with the red overalls is. At the bottom is the mesh for his wrench, on the wrench object. You could put in any of the objects in the blue box to hide the character and the wrench. If you were to put in any of the objects in the hierarchy between the pelvis and the wrench, it would only hide the wrench.

    I hope that makes sense.
     
    Last edited: Jun 27, 2012
  47. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,850
    Hi. The MasterCam asset works as advertised. It has sped up development quite a bit. I have a beta game up based on a right angled grid maze. If you go in one direction..let's call it north the camera.. stays "upright and there is no tilt to the image..the walls remain upright. When I turn to the left or right and navigate an east - west passage the camera is tilted and the walls diagonal. Doesn't bother me but the clients likes his walls upright. What can I add as a code snippet to resolve this for the client?

    TIA
     
  48. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    ippdev, do you have a video or screenshots to show exactly what you mean? Also a screenshot of your camera setup would be helpful.

    From what I gather of your post. It seems like you should be able to use just the core Master Camera script, setting both the vertical min / max to about 85, and the horizontal min / max to equal values, such as both to 90, or whatever is appropriate to line up the grid.
     
  49. unityasoft

    unityasoft

    Joined:
    Oct 28, 2011
    Posts:
    263
    I cannot figure out how to set the height where the rig sits... it seems to just hit the floor.. which, when you zoom would put the camera where the characters legs are!

    I've looked for a solution, the rig sits perfectly on the 3rd person controller character, but on my character it simply doesnt
     
  50. tzvier

    tzvier

    Joined:
    May 20, 2010
    Posts:
    355
    shifty, the solution is in the rig. There is an object named MC.LocationAdjustment which you can use to adjust the camera's effective height. You can find more info here.
     
    Last edited: Aug 5, 2012