Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by CodyMoores · Mar 10, 2014 at 01:19 AM · multiplayerspawningamespawnpoint

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.");
     }
 }        
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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

Comment
Add comment · Show 9 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CodyMoores · Mar 10, 2014 at 01:44 AM 0
Share

How would you go about doing that? Btw you have Skype?

avatar image Joseph123123 · Mar 10, 2014 at 01:48 AM 0
Share

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

avatar image CodyMoores · Mar 10, 2014 at 01:49 AM 0
Share

There is already a pleyer but it's a codcontroller and there's a lot of children on the parent including a couple cameras

avatar image CodyMoores · Mar 10, 2014 at 01:50 AM 0
Share

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

avatar image Joseph123123 · Mar 10, 2014 at 01:53 AM 0
Share

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.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UNET - Server is spawned in correct spawn position but players are spawned "half way" 0 Answers

How to manually handle multiplayer prefabs spawning with our own script ? 0 Answers

MLAPI spawn player prefab 2 Answers

How to get players to re-spawn with a RPC. 0 Answers

Spawn single floor tile at mouse position 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges