Making an NPCPlayerApex attack a player?
Trying to get my NPCPlayerApex to attack a player...
npc.AttackTarget = targetEnt;
npc.StartAttack();
he will not stay shooting if i cick on the target ent fast a few times he will shoot once.

Merged post

                        if (action == Act.Attack && targetEnt != owner.player && distance < targetIgnoreDistance)
                        {
                            if (entity.AttackTarget != targetEnt)
                                entity.AttackTarget = targetEnt;


                            if (distance <= 3)                            
                                entity.StartAttack();
                           else UpdateDestination(targetEnt.transform.position, true);              


Merged post

can not get him to keep shooting when he gets close he stops and wanders off.
            private void Update()
            {                

                if (action == Act.Idle || action == Act.Follow)
                {
                    
                    if (stopFollow)                    
                        StopMoving();
                    else
                    {
                        if (owner != null)
                        {
                            float distance = Vector3.Distance(transform.position, owner.transform.position);
                            if (distance > 3)                            
                                UpdateDestination(owner.transform.position + (-owner.player.eyes.HeadForward() * 2), distance > 10);                            
                            else StopMoving();                            
                        }
                    }                    
                    return;
                }

                if (action == Act.Move)
                {
                    float distance = Vector3.Distance(transform.position, targetPos);

                    if (distance < 1)
                       action = Act.Idle;
                    else
                    {
                        UpdateDestination(targetPos, distance > 5);                        
                    }
                
                 }
                else
                {
                    if (targetEnt == null)
                    {
                        if (!stopFollow)
                            targetEnt = owner.player;

                        action = Act.Idle;
                    }
                    else
                    {
                        float distance = Vector3.Distance(transform.position, targetEnt.transform.position);
                        if (distance > 300.0)
                        {
                            action = Act.Idle;
                            return;
                        }  
                        if (action == Act.Attack && targetEnt != owner.player && distance < targetIgnoreDistance)
                        {
                            if (entity.AttackTarget != targetEnt)
                                entity.AttackTarget = targetEnt;


                            if (distance <= 30.0)                           
                                entity.StartAttack();

                                else   UpdateDestination(targetEnt.transform.position, true); 

                      }                       
                    }
                }
            }

            private void UpdateDestination(Vector3 position, bool run)
            {
                entity.UpdateDestination(position);
                entity.TargetSpeed = run ? entity.Stats.Speed : entity.Stats.Speed * 3.0f;
            }
​