I making some multiplayer deathmatch game that is playing on the same keyboard shared by 3 players.
I want to make some scoring sistem, but i dont know:
-How could i check which player have destroyed another player?
In the other words:
-How could i check who have sent last raycast before target have been destroyed?
Do you have some idea? :))
“same keyboard shared by 3 players”
Sounds messy ha ha.
To get a proper answer we’d need to see your code and how attacking one another is set up.
Other than that I, personally, would put a check within the
if (physics.raycast (me, aim, dist, out Hit){
hit.takedamage bla bla
if (!Hit.transform.gameObject.activeInHierarchy){
myScore++;
}
}
or
if (Hit.transform.gameObject.GetComponent<CodeName>().isDead){
myScore++;
}
}
Like I said, hard to answer without more information from you.
Yes, it’s messy a bit and it’s playing with left hand only
, i love it!
That is a code i was looking for but problem is that it doesn’t work, actually nothing happen, even Debug.Log not working after i destroy someone.
This is my shooting function code:
void Shoot()
{
if (CanShoot())
{
Ray ray = new Ray(spawn.position, spawn.forward);
RaycastHit hit;
float shootDistance = Random.Range(22, 24);
if (Physics.Raycast(ray, out hit, shootDistance))
{
shootDistance = hit.distance;
hit.transform.SendMessage("Cmd_ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
//hit.transform.SendMessage("BulletRayShoot", TheDamage, SendMessageOptions.DontRequireReceiver);
if (hit.transform.gameObject.GetComponent<Hunter>().isDead || !hit.transform.gameObject.activeInHierarchy)
{
if(gameObject.transform.parent.name == "Player1")
{
Debug.Log("Is anybody out there?"); //guess not...
HudManager.hudManager.WinNumCountP1++;
}
}
}
nextPossibleShootTime = Time.time + secondsBetweenShots;
GetComponent<AudioSource>().Play();
}