- Home /
Spawning in a specified location
Hi Everyone I've asked this before in a different question but I have updated my code and I am going to use this code in order to handle the spawning only thing is I need some help in how to set up the spawning when I button is pressed.
Could someone please help me with this?
Here is the code I am using.
GUI.BeginGroup (Rect (Screen.width/2-300, Screen.height/2-200, 600, 500));
GUI.Box (Rect (0,0,400,200), "Game lobby");
var pProtected="no";</br>
if(serverPasswordProtected){</br>
pProtected="yes";</br>
}
GUI.Label (Rect (110,20,150,20), "Password protected: ");
GUI.Label (Rect (250,20,100,100), pProtected);
GUI.Label (Rect (110,40,150,20), "Server title: ");
GUI.Label (Rect (250,40,100,100), serverTitle);
GUI.Label (Rect (110, 60, 150, 20), "GameType Selected: ");
GUI.Label (Rect (250, 60, 100, 100), serverGameTypeSelected);
if (serverGameTypeSelected != "DM")
{
GUI.Label (Rect (110, 120, 150, 20), "Choose Team: ");
//chooseTeamInt = GUI.Toolbar ( Rect (250, 120, 100, 20), chooseTeamInt, chooseTeamNames);
PlayerPrefs.SetString("playerTeam","");
GUI.Button(Rect(200,120,80,20),"Red");
HostLaunchGame();
PlayerPrefs.SetString("playerTeam", "");
GUI.Button(Rect(280,120,80,20),"Blue");
}
GUI.Label (Rect (110,80,150,20), "Players: ");
GUI.Label (Rect (250,80,100,100), currentPlayerCount+"/"+serverMaxPlayers);
GUI.Label (Rect (110,100,150,20), "Current players: ");
GUI.Label (Rect (250,100,100,300), players);
// GUI.Label (Rect (250, 330, 150, 20), "Choose Player");
/* if(Network.isServer){
if(GUI.Button (Rect (110,140,100,20), "Start the game")){
HostLaunchGame();
} }else{ GUI.Label (Rect (110,140,100,40), "Waiting for server..");
}
*/ GUI.EndGroup();
}
}
var lastRegTime : float = -60;
function Update(){
if(Network.isServer && lastRegTime lastRegTime=Time.time;
MasterServer.RegisterHost(gameName,hostSetting_title, "No description");
}
} function HostLaunchGame(){
if(!Network.isServer)
{
RedSpawnPoints = GameObject.FindGameObjectsWithTag("RedSpawnPoints");
return;
}
}
You wouldn't catch me trying to read and decipher that even if you paid me. Please properly format your code and cut it down to relevant areas.
I cut it down as much as I could while keeping the code I need help with
I guess no one can help me with this I'm screwed I've been working at this code trying to figure it out for months now. Well thanks for the help or at least the views Everyone
I don't see where you are attempting to spawn anything. No one is probably answering because they don't understand what you are trying to do and where in this code you are having problems.
I am having problems in the HostLaunchGame function. I want to able to choose I $$anonymous$$m color then spawn in the locations I specify based on the tag
Answer by yezzer · Apr 14, 2012 at 08:08 PM
Format your code correctly.
What exactly are you trying to do? We need more specific information.
What is going wrong? Your code isn't really doing anything..
Answer by reptilebeats · Apr 16, 2012 at 03:26 PM
if i understand right all you want to do is spawn at a point when a point is pressed a lot like a check point system, best way or rather simplest is have a checkpoint manager script which is not destroyed and have the checkpoints update the position in the manager, then when u reload the level assign the either the instantiatian to it or what ever
Actually what I want to do is have the player spawn in a location based on the tag I give them after Team Red or Blue is pressed at the main menu
Your answer
![](https://koobas.hobune.stream/wayback/20220613065907im_/https://answers.unity.com/themes/thub/images/avi.jpg)