Moved from swarm to NavMesh - need to fix the enemy navigation! Review the animation controller to see if anything is being triggered.

This commit is contained in:
2026-06-19 16:20:36 +01:00
parent 14371de4e6
commit e058a7984f
705 changed files with 2046326 additions and 219 deletions

View File

@@ -0,0 +1,65 @@
using UnityEngine;
using Synty.AnimationBaseLocomotion.Samples.InputSystem; // Required to see the InputReader
public class PlayerBuilder : MonoBehaviour
{
[Header("References")]
public InputReader inputReader;
[Header("Repair Settings")]
public float repairRange = 4.0f;
public float repairHealthPerSecond = 100f;
public LayerMask fortificationLayer;
private bool isHoldingRepair = false;
void OnEnable()
{
// Subscribe to the broadcasts when the script turns on
if (inputReader != null)
{
inputReader.onRepairActivated += StartRepairing;
inputReader.onRepairDeactivated += StopRepairing;
}
}
void OnDisable()
{
// Unsubscribe when turned off to prevent memory leaks
if (inputReader != null)
{
inputReader.onRepairActivated -= StartRepairing;
inputReader.onRepairDeactivated -= StopRepairing;
}
}
// These trigger the moment the InputReader hears a button press
private void StartRepairing() { isHoldingRepair = true; }
private void StopRepairing() { isHoldingRepair = false; }
void Update()
{
// If the switch is ON, continuously repair every frame
if (isHoldingRepair)
{
RepairNearbyFortification();
}
}
private void RepairNearbyFortification()
{
Collider[] hits = Physics.OverlapSphere(transform.position, repairRange, fortificationLayer);
foreach (Collider hit in hits)
{
Fortification fort = hit.GetComponentInParent<Fortification>();
if (fort != null && fort.currentHealth < fort.maxHealth)
{
fort.Repair(repairHealthPerSecond * Time.deltaTime);
//add in repair audio and VFX
break; // Only repair one barrier at a time
}
}
}
}