From 75037e551467edb687a51d7d21e62041685a9fae Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Sat, 8 Aug 2020 08:35:36 +0300 Subject: [PATCH] Remove self shooty --- Assets/Scripts/Players/Player.cs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Assets/Scripts/Players/Player.cs b/Assets/Scripts/Players/Player.cs index 5458f08..447cc8d 100644 --- a/Assets/Scripts/Players/Player.cs +++ b/Assets/Scripts/Players/Player.cs @@ -155,23 +155,19 @@ namespace NeonTea.Quakeball.Players { Vector3 From = CameraRoot.position; Vector3 Direction = CameraRoot.forward; - RaycastHit Hit; - if (Physics.Raycast(From, Direction, out Hit)) { - Vector3 To = Hit.point; - ShotDelta = To - GunPoint; - - if (Physics.Raycast(GunPoint, ShotDelta, out Hit, ShotDelta.magnitude + 0.1f, BulletHitLayer)) { - Player Player = Hit.rigidbody.GetComponent(); - if (Player != null) { - Debug.DrawLine(GunPoint, To, Color.red, 5f); - if (Net.Singleton.Instance is Server) { - ((Server)Net.Singleton.Instance).SendHit(Player.NetId); - } - Player.Hit(); - } - } else { - Debug.DrawLine(GunPoint, To, Color.yellow, 5f); + RaycastHit[] Hits = Physics.RaycastAll(From, Direction, BulletHitLayer); + foreach (RaycastHit Hit in Hits) { + Player Player = Hit.rigidbody != null ? Hit.rigidbody.GetComponent() : null; + if (Player == this) { + continue; } + if (Player != null) { + if (Net.Singleton.Instance is Server) { + ((Server)Net.Singleton.Instance).SendHit(Player.NetId); + } + Player.Hit(); + } + break; } GameObject LaserEffect = Instantiate(LaserPrefab);