diff options
Diffstat (limited to 'GameCode/AimForPlayer.cs')
-rw-r--r-- | GameCode/AimForPlayer.cs | 31 |
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); + } + } +} |