using UnityEngine; public class GravityTower : Tower { [SerializeField, Range(0.1f, 10f)] private float radius = 1f; [SerializeField] private Transform orb; [SerializeField] private LayerMask affectedBodies; [SerializeField] private AnimationCurve distToAcceleration; protected override void FixedUpdate() { Collider[] projectilesInRadius = Physics.OverlapSphere(orb.position, radius, affectedBodies); foreach (var projectile in projectilesInRadius) { Rigidbody projectileBody = projectile.GetComponent(); Vector3 projToOrb = orb.position - projectile.transform.position; float dist = projToOrb.magnitude; projectileBody.AddForce(projToOrb.normalized * distToAcceleration.Evaluate(dist)); } } }