-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Darking Assets edited this page Feb 11, 2022
·
11 revisions
Welcome to the Universal-AI-2.0 wiki!
Universal AI is a professional and modular AI solution for everyone. You can check this wiki for deep info about AI with our well-explained API Codes.
- To access the Universal AI scripts and variables, you need to import our custom namespace first. To do so, you can put the code line below on top of your script:
using UniversalAI;
- After importing our namespace, you will need to get the UniversalAICommandManager script to access our API methods. You can call code on Start Or Awake for best results:
CommandManager = YourAIObject.GetComponent<UniversalAICommandManager>();
- Here is a full working example for getting the needed components and calling an API method for example: (You need to attach this to your AI GameObject to make it work).
using UnityEngine;
//Import UniversalAI namespace.
using UniversalAI;
public class APIMethodExample : MonoBehaviour
{
UniversalAISystem AISystem;
UniversalAICommandManager CommandManager;
//On Start, we get the needed components from our AI.
void Start()
{
AISystem = GetComponent<UniversalAISystem>();
CommandManager = AISystem.UniversalAICommandManager;
}
//As an example, it will refill the AI's health when pressing the T key.
void Update()
{
if (Input.GetKeyDown(KeyCode.T))
{
CommandManager.RefillAIHealth();
}
}
}
- AI Take Damage Method, can be called from anywhere.
void TakeDamage(float damageamount, AttackerType attackertype, GameObject attacker)
- Usage:
// The method that will damage your AI, you can leave attacker null if you can't get the damager object.
if(YourAIObject.GetComponent<UniversalAI.UniversalAISystem>() != null)
{
YourAIObject.GetComponent<UniversalAI.UniversalAISystem>().TakeDamage(YourDamage, UniversalAI.UniversalAIEnums.AttackerType.Player, YourPlayerObject);
}
- Command Manager component is the main API handler of the Universal AI 2.0.
- Adds the given GameObject as ignored list for the AI. AI won't detect and will ignore this GameObject.
void AddIgnoredTarget(GameObject Target)
- Removes the given GameObject from the ignored list of the AI. AI will no longer ignore this GameObject.
void RemoveIgnoredTarget(GameObject Target)
- Removes every GameObject from the ignored list of the AI. AI will no longer ignore these GameObjects.
void ClearAllIgnoredTargets()
- Returns The Current Target GameObject Of The AI. Will Return Null If There Is Currently No Target.
GameObject GetTarget()
- Sets the AI's new target.
void SetTarget(GameObject newTarget)
- Sets the new destination for the AI, (if the AI isn't wandering, AI will go to the given destination whenever it wanders).
void SetDestination(Vector3 newDestination)
- Stops The AI Behaviour, So The User Can Add Their Custom Actions / Code / Behaviour etc.
void StopAIBehaviour()
- Starts The AI Behaviour Again.
void StartAIBehaviour()
- Changes the AI's current detection type.
void ChangeDetectionType(UniversalAIEnums.DetectionType detectionType)
- Changes the AI's current faction group.
void ChangeFaction(UniversalAIEnums.Factions factions)
- Returns the AI's current detection type.
UniversalAIEnums.DetectionType GetDetectionType()
- Returns the AI's current faction.
UniversalAIEnums.Factions GetFaction()
- Kills the AI with a delay or instantly.
void KillAI(float delay = 0f)
- Freezes the AI with a delay or instantly.
void FreezeAI(float delay = 0f)
- UnFreezes the AI with a delay or instantly.
void UnFreezeAI(float delay = 0f)
- Revives the AI (can't revive ragdoll death AI).
void ReviveAI()
- Sets the AI health.
void SetAIHealth(float newHealth)
- Refills the AI health.
void RefillAIHealth()
- Returns the AI health.
float GetHealth()
- Sets the AI type.
void ChangeAIType(UniversalAIEnums.AIType AIType)
- Sets the AI confidence.
void ChangeAIConfidence(UniversalAIEnums.AIConfidence AIConfidence)
- Sets the AI wander type.
void ChangeAIWanderType(UniversalAIEnums.WanderType wanderType)
- Returns the current AI type.
UniversalAIEnums.AIType GetAIType()
- Returns the current AI confidence.
UniversalAIEnums.AIConfidence GetAIConfidence()
- Returns the current AI wander type.
UniversalAIEnums.WanderType GetAIWanderType()
- Returns the current distance between AI and AI's current target, (Returns -1 if the target is null).
float GetTargetDistance()
- Enables the health regeneration for the AI
void EnableHealthRegeneration()
- Disables the health regeneration for the AI
void DisableHealthRegeneration()
- To call these methods, you need to say: CommandManager.CompanionCommands instead of only CommandManager.
- Changes the companion AI's attack state (Aggressive, Passive)
void ChangeAttackState(AttackState newAttackState)
- Changes the companion AI's behaviour (Follow, Stay)
void ChangeCompanionBehaviour(CompanionBehaviour newBehaviour)
- To call these methods, you need to say: CommandManager.PetCommands instead of only CommandManager.
- Changes the pet AI's behaviour (Follow, Stay)
void ChangePetBehaviour(PetBehaviour newBehaviour)