Tactical pack not working at all.

jlayton75

New member
Hello! I have been trying for hours and hours to try to get the tactical pack to work. The enemies just walk up to me and don't attack. I have tried multiple examples and looked at the demo. I have attached the script for the agent and the target below.
 

Attachments

  • Target.cs
    979 bytes · Views: 6
  • SkeletonAttackManager.cs
    2.9 KB · Views: 4
  • Target.cs
    979 bytes · Views: 4
To get started does the demo scene work? I haven't integrated UCC with the Tactical Pack yet but should be able to shortly after we release the Deathmatch AI Kit.

Regarding your script, does Attack get called?
Code:
transform.LookAt
Won't do anything because the character controller has control over the transform. You can rotate the character with a new ability, but in this case you should set the LocalLookSource.Target variable instead.

Version 1 of the character controller was integrated with the Tactical Pack and I modified that code a bit to get it working with version 2. This is completely untested but it should work:

Code:
        public void Attack(Vector3 targetPosition)
        {
            if (m_LookSource != null) {
                if (m_LookSource.Target == null) {
                    var targetGameObject = new GameObject(name + " Target");
                    m_LookSource.Target = targetGameObject.transform;
                }
                m_LookSource.Target.position = targetPosition;
            }
            m_CharacterLocomotion.TryStartAbility(m_UseAbility);
        }
 
Hello! I have been trying for hours and hours to try to get the tactical pack to work. The enemies just walk up to me and don't attack. I have tried multiple examples and looked at the demo. I have attached the script for the agent and the target below.
The demo does work. I will try that and get back to you. Thank you!
 
Hi!

I'm having a similar issue - Attack is never called. The AI simply runs to the player/target, then stops. The tree shows Attack in green and no errors are being thrown, but the Attack function doesn't seem to be called at all.
 
Does the demo work for you? Are you using the UCC similar to jlayton? If so you'll need to make the addition above.
 
Does the demo work for you? Are you using the UCC similar to jlayton? If so you'll need to make the addition above.
The demo does work, and I'm not using UCC. Below is the pertinent code, if you wouldn't mind reviewing!

First is the implementation to attack, with non-relevant code removed:

C#:
using BehaviorDesigner.Runtime.Tactical;

    public class AIFighter : MonoBehaviour, IAttackAgent
    {

        [Header("Fighter Attributes")]
        [Tooltip("AttackCooldown")]
        public float repeatAttackDelay;
        public float attackAngle = 1f;

        private float lastAttackTime;
        [SerializeField] float attackDistance; //TODO: Connect to weapon


        public float AttackDistance()
        {
            return attackDistance;
        }

        public bool CanAttack()
        {
            //return lastAttackTime + repeatAttackDelay < Time.time;
            return true;  //return true for testing
        }

        public float AttackAngle()
        {
            return attackAngle;
        }

        public void Attack(Vector3 targetPosition)
        {
           print("Attack");

            transform.rotation = Quaternion.LookRotation(targetPosition - transform.position);
           lastAttackTime = Time.time;
        }
}


This includes the Damageable implementation, which is in the Health script attached to the player in this scene:


C#:
public class Health : MonoBehaviour, IDamageable
    {

        [SerializeField] float health = 100f;

        public void Damage(float amount)
        {
            TakeDamage(amount);
        }

        public bool IsAlive()
        {
            return health > 0f;
        }

        public void TakeDamage(float damage)
        {
            health = Mathf.Max(health - damage, 0);
            print("Damaged");

            if(health <= 0)
            {
                Die();
            }
        }

        private void Die()
        {
            //Die animation
            //Disable enmy
            Debug.Log("Dead");
        }
    }
 
Does CanAttack get called? The easiest way to debug this is to set a breakpoint within Attack.OnUpdate and start stepping through it at line 21. Once the agent is in position CanAttack should then be called.
 
Top