Question by
kylenoll123 · Sep 11, 2016 at 03:48 AM ·
c#if-statementsgameobject.findif-else
How to number players(Simple Probably)
Okay, so.. I want to number my players starting from 1-4 (4 player multiplayer game).
I was wondering if there was a way to see if there was a way to determine if player 1 exists, and if so, set name to player two if there is no player two and so on and so forth..
(Ignore "string name")
public void ChangeName(string name)
{
if(GameObject.Find("Player1"))
{
PNameNumbered.name = "Player2";
}
else if(GameObject.Find("Player2"))
{
PNameNumbered.name = "Player3";
}
else if (GameObject.Find("Player3"))
{
PNameNumbered.name = "Player4";
}
else { PNameNumbered.name = "Player1"; }
I'm not the best and if then statements and I see what is wrong here but I can't seem to figure out a way to make it work the way I want it to. Any help would be flippin fantastic because I'm on the verge of finally getting something done in my game haha thank you in advance!!
Comment
Your answer
Follow this Question
Related Questions
Find instantiated prefab by name 3 Answers
Help with rotation please 2 Answers
problem with lists 0 Answers
Infinite Time inbetween if statements? 2 Answers