- Home /
Mulitplayer problem [Simple Fix] Probably
[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.");
}
}
Answer by Joseph123123 · Mar 10, 2014 at 01:42 AM
There are two options for this to be achieved. 1) you can create the player and in the script disable the object until gui button is clicked. here is what the code would be like (Please note, I only know how to do javascript and script is not tested): var Player : GameObject; Player = false; GUIScreen = true; Function OnGUI(){ if(GUIScreen == true){ if(GUI.Button(Rect(20,250,200,100),"Click Here")){ Player.active = true; GUIScreen = false; } } Option 2 is to instantiate the player on gui click
How would you go about doing that? Btw you have Skype?
Create the player, then position it into the level, then make the script using the code i typed and drag the code into the main camera of the player. Also no I dont have skype
There is already a pleyer but it's a codcontroller and there's a lot of children on the parent including a couple cameras
I wanted to make a level camera and when a button is clicked it switches to the codcontroller or components or with a tag or something
Oh in that case make a new scene and drag the script on the main camera of the new scene and change the gui code to add application.getadditivelevel("levelname") and it will link the two scenes together.