So i’ve figured out collision and all that, now i’m trying to make it so when I die as a player, a GUI button pops up showing me who killed me.
Here’s a picture of the problem
And the code behind it:
private void OnGUI () {
if(myPhotonView.isMine){
if(this.hpWidth<=0.0f){
Debug.Log ("Testing Death");
//Debug.Log ("newest player: "+newestID+" attacking player: "+swordID);
winnerID=2;
check=1;
while(check<newestID)
{check+=1000;
Debug.Log ("check"+check+"newid"+newestID);
if(ownLog[check]>=ownLog[winnerID]){
winnerID=check;
ownLog[check]=0;}
//yield();
}
Debug.Log ("winnerID:"+winnerID);
if (GUI.Button (new Rect (10,10,150,100), "Respawn")) {
this.myPhotonView.RPC("spawnHP", PhotonTargets.AllBuffered);}
}
}
else{
health.transform.localScale = new Vector3(hpWidth, 0.6000001f, 0.5f);
}
if(GUI.Button (new Rect (Screen.width-150, Screen.height-400, 150, 100), "Last Kill by: "+winnerID) && myPhotonView.viewID == winnerID){
//guiText.text ="WinnerID"+ winnerID;
// GUI.Box(Rect (70,70,500,100), "WINNER ID"+winnerID);
//guiText.text = (winnerID).ToString();
if(hpWidth<8.0f)
hpWidth+=1.0f;
}
}
All the GUI stuff at the top is just clarifying what “winnerID” is… you can ignore it. The problem lies with the Button creating a new button when it updates (which also happens in the if(this.hpWidth<=0.0f) statement for some reason