- Home /
Making my player model invisible to my camera
So, in FPS games there is a thing where you can only see your hands, not body, but other players do see your model and animations. Is there a way to do this in Unity?
Thanks for help in advance
Attach a camera to your player object and leave whatever you want in view. Hence the reason for First Person. The other players can see your full game object because their field of view includes everything in front of them, not just their hands.
Just create a new camera layer, then unchecked the camera layer you just created in the drop down menu of the render layer menu in Ur main cameras setting. The camera should now not render the playermodel.
Answer by Addyarb · Apr 12, 2015 at 11:26 PM
Most of the FPS games you play (Call of Duty, Battlefield, etc.) have arm/hand models that they use specifically for those in first person. The rest of the body doesn't actually exist until you die, at which time a ragdoll gets instantiated at your position. You can find some of these hand models (Handy hands) on the asset store, actually.
If you're trying to make it to where you can zoom in and out and still want the nicely modeled hands effect, you can do one of two things:
Carefully place the camera for FPS view so that you don't get any undesirable clipping/cutting of the mesh with your camera. Then, just press a key to zoom in/out from Third Person to First Person.
Have two models. One, your full character, and two, just the modeled hands. If the camera is close enough to being first person, enable the hands and disable the full character. Likewise, if the camera zooms out, disable the hands and enable the full character.
There's only a few instances of popular games that I can think of where you can zoom in seamlessly, one of them being WoW. They use a transparent material for the intermediate stage between Third Person and First Person View. If the camera is close to the character, they turn your character progressively more transparent using the alpha of the material (as well as all of your armor, weapons, etc.).
A few references you'll want to look at if you're interested in achieving these effects:
Changing transparency of material (use alpha instead of RGB)
http://docs.unity3d.com/ScriptReference/Color.Lerp.html http://docs.unity3d.com/Manual/class-Material.html Detect distance between your camera and gameObject to see when to change to transparent: http://docs.unity3d.com/ScriptReference/Vector3.Distance.html Turn gameObjects off and on: http://docs.unity3d.com/ScriptReference/GameObject.SetActive.html
but I need it for multiplayer, it would look really weird if only pairs of hands were to run on a map
Sorry if I didn't explain that very well. Here's the setup.
You (the player with the networkView component that you deter$$anonymous$$e is yours by using networkView.is$$anonymous$$ine) would have just the hands. You could put a script on the root gameObject of the hands that goes something like this..
if(networkView.is$$anonymous$$ine)
gameObject.SetActive(true)
else
gameObject.SetActive(false);
Now, for everyone else, they would see the full models $$anonymous$$us the hands. So on the root gameObject for your full model, you would attach a script that looks something like this:
if(networkView.is$$anonymous$$ine == false)
gameObject.SetActive(true);
else
gameObject.SetACtive(false);
This is how almost every modern FPS handles characters' visibility. This almost always gives a better result, because you aren't having to handle trivial animations (ones that you won't see anyway) for your character, and you get better detail and easier field of view control by just having two arms.
Answer by Calum1015 · Apr 12, 2015 at 11:44 PM
If you are doing a multiplayer game you pretty much need a full model, just put the camera ahead of the head a bit so your not looking through the head, however position the arms, hands and whatever else to the new position. I don't think you can actually disable parts of a single character model just for your view, not without unnecessary scripts that will slow down the game for no reason other than the game creators convenience.
A simple networkView.is$$anonymous$$ine check on the start function is going to cost almost nothing as far as CPU, but running a mecanim animator component, along with instantiating a significantly higher tri-count model and animating it over the lifetime of the game is going to cost exponentially more.