summaryrefslogtreecommitdiff
path: root/GameCode/AimForPlayer.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-10-27 11:05:14 +0800
committerchai <215380520@qq.com>2023-10-27 11:05:14 +0800
commit766cdff5ffa72b65d7f106658d1603f47739b2ba (patch)
tree34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/AimForPlayer.cs
+ init
Diffstat (limited to 'GameCode/AimForPlayer.cs')
-rw-r--r--GameCode/AimForPlayer.cs31
1 files changed, 31 insertions, 0 deletions
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);
+ }
+ }
+}