- Home /
FPS Multiplayer setup - TPS models for other clients
I cannot figure out how to have a first person model for the client playing and a third person model seen by them for every other client.
Are there any good tutorials on this or could someone at least give me a basic idea how to do this? I've searched everywhere and can't find anything that fits what I'm looking for. My client/server setup is based off of the Unity Networking Tutorial. Players can connect (from both mobile and PC) to the server, I just can't get the spawn setup to work.
Movement syncing DOES work if I allow it to spawn first player setups on each client, but floating weapons don't really make sense. I have a spawn object on the map, but its network view seems to be only the server (I've tried doing the spawning using networkView.isMine) and i've tried Network.instantiate to make a local spawn point for everyone, but that doesn't work either and wouldn't solve movement syncing.
Any help is appreciated.
Alright a little update. I've found one way to do it is to have the FPS and TPS models spawned, but then delete the mesh for the one not needing to be rendered. This seems like it'd work, but this is aimed for mobile and it seems like it might be inefficient. Is there a better way?
Also something to add, my player is a custom rigidbody setup and I am using the NetworkRigidbody.cs from the Networking Tutorial to sync movement.
Answer by nixtwiz · Sep 24, 2012 at 02:36 AM
Solved my own problem. Went with spawning the first and third player setups in the same prefab and then deleting one depending on networkView.isMine. Here's the code I used for anyone that needs it. This code would go on the player prefab that is instantiated, and the BodyMesh and FirstPersonSetup are set in the inspector from objects in this prefab.
function Awake(){
//on spawn, check if this object is controlled by the client
if(networkView.isMine){
//if it is, delete the third person mesh
Destroy(BodyMesh.gameObject);
//Set everything else the Player needs on startup
}
else{
//if it isn't, delete the first person setup
Destroy(FirstPersonSetup.gameObject);
}
}
function Update(){
if(networkView.isMine){
//if object is the client's
//control code goes here
}
}
I've tried this for photon and it didn't work. Any suggestions?
Sorry haven't worked with Photon. You'd probably be better off asking that as a new question or starting a thread in the forums (Unity and ExitGames). I can't imagine it'd be too different though, but I'm guessing it has its own version of "networkView.is$$anonymous$$ine" so you might want to look into that.
Alright. I've asked on here and haven't gotten a response yet so I guess it's off to ExitGames :/
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Using AssignClientAuthority 0 Answers
Network Multiplayer 0 Answers
Networking Unknown message ID 0 Answers
Unity Multiplayer - OnStartLocalPlayer() called multiple times 0 Answers