🛠️Custom Integrations

Here, you will learn how to make your own integrations.

This page is for you to learn how to integrate Universal AI with your controller.

Damage Your Player

  1. Go to HERE and do the how-to damage your player part first.

  2. Open the UniversalAIDamageReceiver.cs script and we will edit it.

  3. Go to the TakeDamage(float damage) void and start writing your code like below to an empty space.

So, here you should just write your player damage code and for damage use the damage parameter in the void. Example:

public void TakeDamage(float damage)
{
  GetComponent<MyController>().ReceiveDamage(damage);
}

And that's all, now your Receive Damage void should be called with the damage amount!

Damage your AI

  1. Open your code that handles weapon damages script and we will edit it.

So, if you are using raycast to make damage read this part.

Go to the void you are using raycast and add these lines: (Example)

//Your Weapon Raycast class
using UniversalAI;

//Dont forget using UniversalAI;

public float MyDamage = 30;

//This is a example void, you can use your own void too!
public void MyRaycast
{
  RaycastHit hit;
  
  Physics.Raycast(transform.position, transform.forward, out hit, 10)
  {
    UniversalDamageable damageable = hit.GetComponent<UniversalDamageable>();
    
    if(damageable != null)
    {
      damageable.TakeDamage(MyDamage);
    }
  }
}

And now all should work and your raycast should hit/damage the AI !!

Last updated