Tactical Pack Setup

My Script:

C#:
using BehaviorDesigner.Runtime.Tactical;
using BehaviorDesigner.Runtime.Tactical.Tasks;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FlyingEnemy : MonoBehaviour, IAttackAgent
{
    public float shootForce;
    public GameObject bullet;
    public Transform firePoint;
    public float fireRate = 0.1f;
    public float attackDistance;
    public float attackAngle;

    float count;

    public void Attack(Vector3 targetPosition)
    {
        count = 0;
        transform.LookAt(targetPosition);
        Transform Bullet = Instantiate(bullet.transform, firePoint.position, Quaternion.LookRotation(targetPosition));
        Bullet.GetComponent<Rigidbody>().AddForce((targetPosition - Bullet.position).normalized * shootForce, ForceMode.Impulse);
    }

    public float AttackAngle()
    {
        return attackAngle;
    }

    public float AttackDistance()
    {
        return attackDistance;
    }

    public bool CanAttack()
    {
        if(count >= fireRate)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        count += Time.deltaTime;
    }
}
And:
C#:
using BehaviorDesigner.Runtime.Tactical;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AgentHealth : MonoBehaviour, IDamageable
{

    public float health = 50f;


    public void Damage(float amount)
    {
        health -= amount;
    }

    public bool IsAlive()
    {
        if (health <= 0f)
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
 
It looks like you are getting an exception which could be the problem. Beyond that I would start with just the attack task and getting that to work. You can then add more complexity to your behavior tree.
 
Top