From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Fri, 27 Oct 2023 11:05:14 +0800
Subject: + init

---
 GameCode/AimForPlayer.cs | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 GameCode/AimForPlayer.cs

(limited to 'GameCode/AimForPlayer.cs')

diff --git a/GameCode/AimForPlayer.cs b/GameCode/AimForPlayer.cs
new file mode 100644
index 0000000..5a9ab24
--- /dev/null
+++ b/GameCode/AimForPlayer.cs
@@ -0,0 +1,31 @@
+using UnityEngine;
+
+public class AimForPlayer : MonoBehaviour
+{
+	public enum Target
+	{
+		OtherPlayer,
+		Closest
+	}
+
+	public float upOffset;
+
+	public Target target;
+
+	private SpawnedAttack spawned;
+
+	private void Start()
+	{
+		spawned = GetComponentInParent<SpawnedAttack>();
+	}
+
+	private void Update()
+	{
+		Player player = null;
+		player = ((target != 0) ? PlayerManager.instance.GetClosestPlayer(base.transform.position, needVision: true) : PlayerManager.instance.GetOtherPlayer(spawned.spawner));
+		if ((bool)player && PlayerManager.instance.CanSeePlayer(base.transform.position, player).canSee)
+		{
+			base.transform.rotation = Quaternion.LookRotation(player.transform.position + Vector3.up * Vector3.Distance(player.transform.position, base.transform.position) * 0.1f * upOffset - base.transform.position, Vector3.forward);
+		}
+	}
+}
-- 
cgit v1.1-26-g67d0