Check if the local player has killed someone?

Hi, I am creating an FPS and I am stuck on how to make it so when the local player gets a kill, it comes up with a GUI box saying "Enemy Killed +10". I have read the Documentation and I don't have the money the buy the $100 guide from the asset store so if someone could help me I would be very greatful.

Here is the Health script:
using UnityEngine;
using System.Collections;

public class PlayerHealth : Photon.MonoBehaviour
{
	
	public float Health = 100;
	[HideInInspector]
	public GameManager Manager;
	public bool DoesAllow = false;
	//public Texture2D HitTexture;
	private bool DoesShow = false;
	//public DamageHud hud;
	public float hitEffectTime;
	//[HideInInspector]
	
	public float hittimes;
	
	
	
	// Use this for initialization
	void Start ()
	{
		Manager = GameObject.Find("Code_game").GetComponent<GameManager>();
		hittimes = 0;
	}
	
	// Update is called once per frame
	void Update ()
	{
	
		hittimes -= Time.deltaTime;
		//if(Health <= 80&&DoesAllow == true){
		//	DoesShow = true;
		//}
		//else
		//	DoesShow = false;
		
		//if(Health == 0){
		//	BroadcastMessage("GiveXP",10,SendMessageOptions.DontRequireReceiver);	
		//}
		
	}
	
	
	void TakeDamage(float Adj){
		Health -= Adj;
	}
	
	void DoRedScreen(){
		hittimes = hitEffectTime;	
	}
	
	
	
	void OnGUI(){
	//	if(DoesAllow == true)
	//		GUI.Label(new Rect(800,500,400,400),Health.ToString());
		
		
		//if(DoesShow = true)
		//	GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),HitTexture);7
		//if(DoesShow = true)
		//hittimes -= Time.deltaTime;
		//if(photonView.isMine == true){
			
		//	GUI.color = new Color(1,1,1,hittimes);
		//	GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),HitTexture);
		//}
		
		
	//}	
	}
}

Here is the part where the Player actually dies:
if(HealthCode.Health <= 0)
			photonView.RPC("Det",PhotonTargets.All);

	[RPC]
	void Det(){
			PublicPlayer.transform.parent = null;
			PublicPlayer.SetActiveRecursively(true);
			Rigidbody[] bodys = PublicPlayer.GetComponentsInChildren<Rigidbody>();
			foreach(Rigidbody body in bodys){
				body.isKinematic = false;
			}
			
		if(photonView.isMine){
			//Transform SpawnPos= HealthCode.Manager.PlayerSpawns[Random.Range(0,HealthCode.Manager.PlayerSpawns.Length)];
			//PhotonNetwork.Instantiate("SASBloke_AimRag",transform.position,transform.rotation,0);
			HealthCode.Manager.hasSpawn = false;
			HealthCode.Manager.ShowLeave = false;
			//PublicPlayer.AddComponent<PhotonView>();
			
				
			PhotonNetwork.Destroy(this.gameObject);
			
			
		}
		
	}


Thanks
Tz
Bon-Fire

:D

Comments

  • Hey iiTZJOEY,

    with this topic, I would suggest you have a look at the Agny Bots Photon modification, which somehow covers this and other situations. Simply search for "angybots photon" in the Unity Asset Store.

    hope that helps,
    Tim
  • Tim wrote:
    Hey iiTZJOEY,

    with this topic, I would suggest you have a look at the Agny Bots Photon modification, which somehow covers this and other situations. Simply search for "angybots photon" in the Unity Asset Store.

    hope that helps,
    Tim
    Does it? when you get a kill on it, no gui is shown. Unless you were talking and the health script, if so I already have one.
  • We can't support you in writing Unity GUI code, sorry. The Angry Bots demo shows how to pass the info "i hit you" and "this is my health" to other players. Photon and our demos are only about the actual networking, not about how to display the info in various combinations.
    If the question is more about Unity than networking, then you should look into answers.unity3d.com and their forum.
  • I know this is an old thread but I still have this doubt and for some reason I think the Angry bots demo is unavailable, could you please provide the demo link please?