FPS game SCORBOARD implementation ?
Hello guys,
My players when kill someone how can I understand who killed who , and increase kill score or death score , I am kinda new on photon ?
this is my bullet script =
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag(TagManager.PLAYER_TAG))
{
myBody.velocity = Vector2.zero;
CancelInvoke("DeactivateBullet");
anim.enabled = true;
anim.SetBool(TagManager.EXPLODE_ANIMATION_PARAMETER, true);
if (!dealthDamage)
{
dealthDamage = true;
collision.GetComponent<HealthSystemLast>().GiveDamageToPlayer();
}
}
And this is my HEALTH SCRIPT
public class HealthSystemLast : MonoBehaviourPunCallbacks,IPunObservable
{
[SerializeField]
private int health = 100;
private int currentHealth;
[SerializeField]
private HealthBar healthBar;
// [SerializeField]
private Text killText;
private void Start()
{
currentHealth = health;
healthBar.SetMaxHealth(health);
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
// sync health
if (stream.IsWriting)
{
stream.SendNext(health);
}
else
{
// if we are reading
health = (int)stream.ReceiveNext();
}
}
[PunRPC]
public void GiveDamageToPlayer()
{
health -= 10;
healthBar.SetHealth(health);
if(health <= 0)
{
StartCoroutine(Respawn());
}
}
private void SetKillText()
{
// killText.text = killcount.ToString()+" Deaths";
}
IEnumerator Respawn()
{
transform.position = new Vector3(1115, 109, 110);
health = 100;
healthBar.SetHealth(health);
GetComponent<PlayerMovement>().enabled = false;
GetComponent<PlayerShootingManager>().enabled = false;
yield return new WaitForSeconds(3.0f);
SetKillText();
GetComponent<PlayerShootingManager>().enabled = true;
transform.position = new Vector3(0, 10, 0);
GetComponent<PlayerMovement>().enabled = true;
}
}
Also some times bullets are touching player and health not decrase