Ability to Restart Level, Player Spawning and a Test Level added + Bug Fix

This commit is contained in:
2022-02-25 13:49:11 +03:00
parent 7939328be7
commit cc479e14ba
9 changed files with 1270 additions and 1303 deletions

View File

@@ -21,7 +21,7 @@ namespace AI
protected bool isShooting = false;
protected IMovement movement = null;
protected bool canShoot => (target.transform.position - transform.position).sqrMagnitude < attackRangeSquared && target != null;
protected bool canShoot => target != null && (target.transform.position - transform.position).sqrMagnitude < attackRangeSquared;
public UnityEvent OnShoot { get; protected set; } = null;
@@ -36,11 +36,13 @@ namespace AI
cooldownPerShoot = 1f / attacksPerSecond;
attackRangeSquared = attackRange * attackRange;
OnShoot = new UnityEvent();
UpdateTarget(FindObjectOfType<Player.PlayerController>()?.transform);
}
protected virtual void Start()
=> movement = transform.GetComponentInParent<IMovement>();
{
movement = transform.GetComponentInParent<IMovement>();
UpdateTarget(FindObjectOfType<Player.PlayerController>()?.transform);
}
protected virtual void Update()
{