I am making a multiplayergame and i want to record witch played dealt a certan blow of damage by entering the amount of damage and then the damagedealers name. But i dont know how to do it.
Heres my code:
using UnityEngine;
using System.Collections;
public class Explosion : Photon.MonoBehaviour {
public float radius;
public float power;
public float damage;
public float falloff;
public class Damage {
public float damage;
public PhotonPlayer pl;
}
// Update is called once per frame
void Awake () {
Vector3 explosionPos = transform.position;
Collider[] colliders = Physics.OverlapSphere(explosionPos, radius);
foreach (Collider hit in colliders) {
if (hit && hit.rigidbody)
hit.rigidbody.AddExplosionForce(power, explosionPos, radius, 3.0F);
if (hit.gameObject.tag == "Player") {
AcensionPlayermovement script = hit.gameObject.GetComponent<AcensionPlayermovement>();
float distance = Vector3.Distance(hit.transform.position, transform.position);
//Here i want to send the players name aswell
script.ApplyDamage (damage - (distance /falloff+ distance));
}
}
}
}
and here:
// and here i want to recive that players name
public void ApplyDamage (float Damage){
print(Damage);
Currenthealth =Currenthealth - Damage;
return;
}
thanks in advance for your help!