|
Hi, now I have an additional problem. I would like to set up a player prefab with an animated playermesh and a weaponmesh. The prefab contains a camera that should render only the weapon but not the player's body. Now let's look what happens if someone plays the game:
The problem: Can I change the layer of a GameObject during runtime ? If this is possible I could make a check for networkView.isMine and change the layer individually on each machine. Is there something like camera.Ignore(GameObject) ? If there's something like this, how can I still render the children of the ignored GameObject ?
(comments are locked)
|
|
You can most definitely change the layer during runtime... From the scripting reference:
If you want to continue with your way, you can setup the layers (for example) as MyWeapon, MyPlayer, OtherWeapons, OtherPlayers. Then, you can use Camera.cullingMask on your camera to decide what it renders, and what not. You can either edit your prefab of the player (change the camera's cullingMask in the inspector) Or you can have a variable in your spawn script:
If it's public you can edit it in the inspector, just like you edit the cullingMask. When you instantiate your local player, just assign:
When you instantiate a remote player, move the relevant game objects on the instantiated player to the appropriate layers (OtherPlayers, OtherWeapons). The camera will do the rest. Alternatively, you can also create two prefabs - one for a local player, one for a remote one. BTW, just out of curiosity - why would you not want to display other player's weapons? (Unless the weapon is a heavy object and you want to replace it with some low poly object) I don't know how to turn my weapon object correctly. So I have two objects: The weapon from which shots are fired. It's parented to the camera and moves just like in any other fps. Moreover I have the player oject. It's animated to walk and jump. However I don't know how I can correctly turn the player's hands in the direction the camera is facing. Therefore I render just the playermesh and not the weapon for other machines and the other way round on the local machine. To the player it looks like the shots are instantiated in mid-air but that's better than a weapon not connected to the player.
May 08 '11 at 08:05 PM
lhk
If you know how to turn the player's upper body up and down with a script, I would appreciate it very much, if you could help me. Up to know everybody is fighting unarmed persons that shoot from nowhere and can't look up and down.
May 08 '11 at 08:07 PM
lhk
I could start and explain exactly how to do it, but I think it's much more productive if you just change the "Head Look Controller" that Unity have on their resources section (http://unity3d.com/support/resources/unity-extensions/head-look-controller). It's meant to turn the head towards something interactively, but I think it can easily be changed to effect the torso if necessary :)
May 09 '11 at 08:56 AM
Cyb3rManiak
(comments are locked)
|
