From 231054030b6e1014ae38d7647d0544e9377c7aa9 Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Sat, 8 Aug 2020 16:11:29 +0300 Subject: [PATCH] Fix hit sorting --- Assets/Scripts/Players/Player.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Assets/Scripts/Players/Player.cs b/Assets/Scripts/Players/Player.cs index d46f81c..6a65034 100644 --- a/Assets/Scripts/Players/Player.cs +++ b/Assets/Scripts/Players/Player.cs @@ -179,6 +179,7 @@ namespace NeonTea.Quakeball.Players { Vector3 From = CameraRoot.position; Vector3 Direction = CameraRoot.forward; RaycastHit[] Hits = Physics.RaycastAll(From, Direction, 1000f, BulletHitLayer); + System.Array.Sort(Hits, (a, b) => { return a.distance.CompareTo(b.distance); }); foreach (RaycastHit Hit in Hits) { ShotDelta = Hit.point - GunPoint; Player Player = Hit.rigidbody != null ? Hit.rigidbody.GetComponent() : null;