the sun is leaking.

This commit is contained in:
reisenlol 2026-02-01 23:23:15 -08:00
parent 43a0b83748
commit b968ed3060
No known key found for this signature in database
4 changed files with 212 additions and 70 deletions

View file

@ -4,7 +4,9 @@ using UnityEngine;
public class Enemy : Entity
{
[Header("Targetting")]
public Entity closestTarget;
public Entity closestTarget;
public float engagementRange;
public bool detectedPlayer = false;
[Header("Direction")]
public float acceleration;
public Transform[] possibleDirections;
@ -23,7 +25,11 @@ public class Enemy : Entity
protected override void FixedUpdate()
{
if (stalled || !closestTarget)
if (!detectedPlayer && Vector3.Distance(transform.position, closestTarget.transform.position) < engagementRange)
{
detectedPlayer = true;
}
if (stalled || !closestTarget || !detectedPlayer)
{
rb.VelocityTowards(Vector2.zero.ScaleToMagnitude(speed), acceleration);
}