Remove self shooty

This commit is contained in:
Jens Pitkänen 2020-08-08 08:35:36 +03:00
parent a028ca93c9
commit 75037e5514
1 changed files with 12 additions and 16 deletions

View File

@ -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<Player>();
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<Player>() : 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);