UFPS Integration Tutorial - Black-Horizon-Studios/Emerald-AI GitHub Wiki

UFPS Integration Tutorial

This tutorial will get Emerald AI working with UFPS version 1.7.5. This will allow users to use UFPS to damage, both ranged and melee, Emerald AI agents as well as have Emerald AI damage the UFPS player. Note: This tutorial requires adding a few lines to a couple UFPS scripts and some basic understanding of minor editing of scripts.

Note: This tutorial has been updated to included explosive damage. Ensure that you follow the vp_Explosion step.

In order for Emerald AI to work correctly, your scenes must be baked with Unity’s NavMesh. For a quick guide on how to do so, see Unity’s guide here: Baking your Scene with Unity's NavMesh. Your AI’s attack animations will also need to have Attack Animation Events for ranged/melee attacks. See the tutorial on doing this here: Attack Animation Event Tutorial

vp_FXBullet Code Snippet

This code should be placed right under the line m_Transform.position = m_Hit.point; within the vp_FXBullet script. Save the script when you’re done.

//Damage Emerald AI object
if (m_Hit.collider.gameObject.tag == "Emerald AI")
{
   if (m_Hit.collider.gameObject.GetComponent<EmeraldAI.EmeraldAISystem>() != null)
   {
      EmeraldAI.EmeraldAISystem EmeraldComponent = m_Hit.collider.gameObject.GetComponent<EmeraldAI.EmeraldAISystem>();
      EmeraldComponent.Damage((int)Damage, EmeraldAI.EmeraldAISystem.TargetType.Player, m_Source.transform, 400);
   }
}

vp_Explosion Code Snippet

This should be placed within the TryDamage function at the very top within the vp_Explosion script. This is what allows explosive weapons to affect Emerald AI agents.

//Damage Emerald AI object
if (m_TargetCollider.gameObject.tag == "Emerald AI")
{
   if (m_TargetCollider.gameObject.GetComponent<EmeraldAI.EmeraldAISystem>() != null)
   {
      EmeraldAI.EmeraldAISystem EmeraldComponent = m_TargetCollider.gameObject.GetComponent<EmeraldAI.EmeraldAISystem>();
      EmeraldComponent.Damage((int)Damage, EmeraldAI.EmeraldAISystem.TargetType.Player, m_Source.transform, 400);
   }
}

EmeraldAIPlayerDamage Code Snippet

This code should be placed right under the last commented section within the EmeraldAIPlayerDamage script. Ensure that you have also added the line DamageUFPSPlayer(DamageAmount); within the SendPlayerDamage function. Save the script when you’re done.

void DamageUFPSPlayer(int DamageAmount)
{
   if (GetComponent<vp_FPPlayerDamageHandler>())
   {
      GetComponent<vp_FPPlayerDamageHandler>().Damage((float)DamageAmount);
   }
}

This concludes the UFPS integration tutorial, if something isn’t working correctly, re-watch the video to ensure nothing was missed. If you’re having issues with implementing UFPS, and you’ve gone through the video tutorial, support can be provided at: [email protected]