Tactical-Pack - A* Integration - Defend - Defender doesn't stop chasing when intruder is outside defend radius

SubliminalSS

New member
Please note this may be by design, but it didn't match my expected behaviour so I thought a bug report might be a way to discuss.

Summary:
When I place a 2d sprite (Which uses A* Pathfinding) on a location to defend and give it a radius. It chases all targets until the actual defender hits the boundary.

In my case, my attacker is an aircraft sprite so its speed is significantly higher than the defender, it makes no sense for the Land unit sprite to be chasing all the way to the boundary when the attacker is long gone.


I Modified the condition in the Integration Defend.cs to be like so and it works well but would like to suggest it makes it back into the core.
C#:
                // Stop attacking if the target gets too far away from the defend object.
                if (
                        (tacticalAgent.TargetTransform.position - defendObject.Value.transform.position).magnitude > maxDistance.Value ||
                        (transform.position - defendObject.Value.transform.position).magnitude > maxDistance.Value ||
                        !tacticalAgent.TargetDamagable.IsAlive()
                    ) {
                    tacticalAgent.TargetTransform = null;
                    tacticalAgent.TargetDamagable = null;
                    tacticalAgent.AttackPosition = false;
                } else {
                    // The target is within distance. Keep moving towards it.
                    tacticalAgent.AttackPosition = true;
                    if (MoveToAttackPosition()) {
                        tacticalAgent.TryAttack();
                    }
                }

Reproduction Steps:
Using A* Pathfinding Tactical Pack Integration


Place a defender on the game world.
Give it a speed of 2.
Set it to "Defend" a point on the map.

Place an "attacker" on the game world.
Give it a speed of 20.
Move it into the range of the point and quickly move it away.

Actual Outcome
Defender tracks and chases the attacker until the defender hits its radius limit and then travels back

Expected Outcome
Defender tracks until the attacker is out of range and then travels back.


Thanks!
 
Last edited:
Top