[Move to second paragraph if you don’t wanna read the long first one]
So Im currently using an FPS Kit OneManArmy made from www.armedunity.com and I implemented a multiplayer system with PUN which was also a package from Armed Unity [Both premium] and I got it all working, it’s just, when I spawn, my player is all weird. For instance, My minimap moves, I can hear footsteps I can see my arms and gun in front of me and they will move but the main camera doesn’t move.
I was wondering if anyone knew how to make a camera with a script attached that will spawn the player in when a Button is clicked and switch to the Player controller. It seems like a simple task, but I need someones help. Thanks to anyone who helps!
- Cody.
I think this script may have something to do with it:
public class AU_GameManager extends Photon.MonoBehaviour {
var myCustomProp : String;
var connectedPlayerList : Array = new Array(PhotonPlayer);
private var playerName : String;
var levelCamera : Camera;
var audioListener : AudioListener;
var pv : PhotonView;
var allSpawnPoints : GameObject[];
@HideInInspector
var playerInGame : boolean;
function Awake () {
PhotonNetwork.isMessageQueueRunning = true;
playerName = PhotonNetwork.player.name;
//Example how to use custom properties.
//Set:
//var setCustomProp : ExitGames.Client.Photon.Hashtable = new ExitGames.Client.Photon.Hashtable();
//setCustomProp.Add("MyString", myCustomProp);
//PhotonNetwork.room.SetCustomProperties(setCustomProp);
//Get:
myCustomProp = PhotonNetwork.room.customProperties["MyString"];
}
function SpawnPlayer(){
var spawnPoint : GameObject = allSpawnPoints[Random.Range(0, allSpawnPoints.Length)];
var nPlayer : GameObject = PhotonNetwork.Instantiate("PlayerPrefab", spawnPoint.transform.position, spawnPoint.transform.rotation, 0);
if(playerInGame == false){
nPlayer.GetComponent("PlayerConfig").LocalPlayer();
nPlayer.name = playerName;
LevelCamera(false);
playerInGame = true;
}
}
function LevelCamera(action : boolean){
levelCamera.enabled = action;
audioListener.enabled = action;
}
///////////////////////////
// Photon Functions
///////////////////////////
function OnLeftRoom () {
Debug.Log ("*** OnLeftRoom ()..... Called once the local user left a room.");
LeftRoom();
}
function OnDisconnectedFromPhoton () {
Debug.Log ("*** OnDisconnectedFromPhoton ().... Called after disconnecting from the Photon server. In some cases, other events are sent before OnDisconnectedFromPhoton is called.");
LeftRoom();
}
function LeftRoom(){
PhotonNetwork.isMessageQueueRunning = false;
Application.LoadLevel ("MainMenu");
}
function OnPhotonPlayerConnected () {
Debug.Log("*** OnPhotonPlayerConnected()..... Player Connected.");
}
}