using System; using Opsive.UltimateCharacterController.Traits; using UnityEngine; namespace PixelWizards.GameSystem { /// <summary> /// Quick tutorial for anyone that's using Opsive UCC and want to integrate it with Blaze, it's super simple: /// 1) setup your AI with Blaze /// 2) Add a Rigidbody /// 3) add (from Opsive): Attribute Manager & Health components /// 4) add 'on damage' and 'on death' events to the Health components /// 5) add the attached components (Damage Handler) to the AI /// 6) setup the 'Take Damage' and 'On Death' events to point at the damage handler script: /// </summary> public class DamageHandler : MonoBehaviour { private BlazeAI blaze; private Health health; private void Start() { blaze = gameObject.GetComponent<BlazeAI>(); health = gameObject.GetComponent<Health>(); } /// <summary> /// Add this to the 'On Damage Event' on the UCC Health component /// </summary> public void TakeDamage(Single amount, Vector3 position, Vector3 force, GameObject thisObject) { if (thisObject != null) { Debug.Log("Take Damage! " + amount + " hit by " + thisObject.name); // tell blaze that we were hit blaze.Hit(thisObject); } } /// <summary> /// Add this to the 'On Death' on the UCC Health component /// </summary> public void OnDeath(Vector3 position, Vector3 force, GameObject thisObject) { if (thisObject != null) { Debug.Log("We died! - Killed by : " + thisObject.name); // tell blaze that we died blaze.Death(false, thisObject); } } } }