Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Emerald AI 3.2 (New Sound Detection) - The Ultimate Universal AAA Quality AI Solution

Discussion in 'Assets and Asset Store' started by BHS, Jun 26, 2015.

  1. MonstaManly

    MonstaManly

    Joined:
    Apr 18, 2020
    Posts:
    11
  2. itsmikeski

    itsmikeski

    Joined:
    Nov 25, 2021
    Posts:
    5
    This won’t work because it means every enemy in that wave would trigger the next wave event when they die.
     
  3. MonstaManly

    MonstaManly

    Joined:
    Apr 18, 2020
    Posts:
    11
    Hey would anyone have a fix to a issue that popped up overnight? For some reason all melee attacks from my AI no longer damage the character but Ranged attacks work perfectly for some reason???
     
  4. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    I wrote my own my wave system use Emerald
     
  5. itsmikeski

    itsmikeski

    Joined:
    Nov 25, 2021
    Posts:
    5
    Care to share?
     
  6. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    Keep in mind these are from Emerald 2.4 and some of the code has change.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using EmeraldAI.Utility;
    5. using EmeraldAI;
    6. using EmeraldAI.Example;
    7.  
    8.  
    9. public class EmeraldAIWaveSpawner : MonoBehaviour
    10. {
    11.     public Transform SpawnPoint;
    12.     public Transform Destination;
    13.     private Transform myTransform;
    14.     public List<GameObject> SummonCharacters = new List<GameObject>();
    15.     private List<GameObject> myCharacters = new List<GameObject>();
    16.     private int CurrentCompanions = 0;
    17.     public int NumberofWaves = 3;
    18.     private int CurrentWaves = 0;
    19.     public AudioClip StartWaveSoundClip;
    20.     public AudioClip EndWaveSoundClip;
    21.  
    22.     // Start is called before the first frame update
    23.     void Start()
    24.     {
    25.         for (int i = 0; i < SummonCharacters.Count; i++)
    26.         {
    27.             myCharacters.Add(SummonCharacters[i]);
    28.         }
    29.         CurrentCompanions = myCharacters.Count;
    30.     }
    31.  
    32.     // Update is called once per frame
    33.     void Update()
    34.     {
    35.         if (CurrentWaves < NumberofWaves)
    36.         {
    37.             if (CurrentCompanions <= myCharacters.Count)
    38.             {          
    39.                 for (int i = 0; i < myCharacters.Count; i++)
    40.                 {
    41.                     Vector3 SpawnPosition = SpawnPoint.transform.position + SpawnPoint.transform.forward * 5 + (Random.insideUnitSphere * 2);
    42.                     SpawnPosition.y = SpawnPoint.transform.position.y;
    43.                     GameObject SpawnedAI = EmeraldAIObjectPool.Spawn(SummonCharacters[i], SpawnPosition, Quaternion.identity);
    44.  
    45.                     //Set an event on the created AI to remove the AI on death
    46.                     SpawnedAI.GetComponent<EmeraldAISystem>().DeathEvent.AddListener(() => { RemoveAI(); });
    47.                     CurrentCompanions++;
    48.  
    49.                     SpawnedAI.GetComponent<EmeraldAIEventsManager>().SetDynamicWanderPosition(Destination);
    50.                 }
    51.                 CurrentWaves++;
    52.                 PlayAudioClip(StartWaveSoundClip);
    53.             }
    54.            
    55.            
    56.         }
    57.  
    58.     }
    59.  
    60.  
    61.     public void RemoveAI()
    62.     {
    63.         CurrentCompanions--;
    64.     }
    65.  
    66.     private void PlayAudioClip(AudioClip audioClip)
    67.     {
    68.         if (audioClip == null) return;
    69.         var audioSource = GetComponentInParent<AudioSource>();
    70.         if (audioSource == null)
    71.         {
    72.             if (transform.parent == null)
    73.             {
    74.                 AudioSource.PlayClipAtPoint(audioClip, FindObjectOfType<SmoothMouseLook>().transform.position);
    75.                 return;
    76.             }
    77.             audioSource = transform.parent.gameObject.AddComponent<AudioSource>();
    78.         }
    79.         audioSource.spatialBlend = 0f;
    80.         audioSource.PlayOneShot(audioClip);
    81.     }
    82. }
    83.  
     
  7. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    Here is another for my gauntlet that I made.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using EmeraldAI.Utility;
    5. using EmeraldAI;
    6. using EmeraldAI.Example;
    7.  
    8. public class EmeraldGauntletSpawner : MonoBehaviour
    9. {
    10.     public Transform SpawnPoint;
    11.     public Transform Destination;
    12.     private Transform myTransform;
    13.     public List<GameObject> SummonCharacters = new List<GameObject>();
    14.     private List<GameObject> myCharacters = new List<GameObject>();
    15.     private int CurrentCompanions = 0;
    16.     private int MaxCompanions = 0;
    17.     private int CurrentNPCSpawn = 0;
    18.     public AudioClip StartWaveSoundClip;
    19.     public AudioClip EndWaveSoundClip;
    20.  
    21.     // Start is called before the first frame update
    22.     void Start()
    23.     {
    24.         for (int i = 0; i < SummonCharacters.Count; i++)
    25.         {
    26.             myCharacters.Add(SummonCharacters[i]);
    27.         }
    28.         MaxCompanions = myCharacters.Count;
    29.     }
    30.  
    31.     // Update is called once per frame
    32.     void Update()
    33.     {
    34.  
    35.         if (CurrentNPCSpawn < MaxCompanions)
    36.         {
    37.             if (CurrentCompanions < 1)
    38.             {
    39.  
    40.                     Vector3 SpawnPosition = SpawnPoint.transform.position + SpawnPoint.transform.forward * 5 + (Random.insideUnitSphere * 2);
    41.                     SpawnPosition.y = SpawnPoint.transform.position.y;
    42.                     GameObject SpawnedAI = EmeraldAIObjectPool.Spawn(SummonCharacters[CurrentNPCSpawn], SpawnPosition, Quaternion.identity);
    43.  
    44.                     //Set an event on the created AI to remove the AI on death
    45.                     SpawnedAI.GetComponent<EmeraldAISystem>().DeathEvent.AddListener(() => { RemoveAI(); });
    46.                     CurrentCompanions++;
    47.  
    48.                     SpawnedAI.GetComponent<EmeraldAIEventsManager>().SetDynamicWanderPosition(Destination);
    49.  
    50.                 CurrentNPCSpawn++;
    51.                 PlayAudioClip(StartWaveSoundClip);
    52.             }
    53.  
    54.  
    55.         }
    56.  
    57.  
    58.  
    59.  
    60.     }
    61.  
    62.  
    63.     public void RemoveAI()
    64.     {
    65.         CurrentCompanions--;
    66.     }
    67.  
    68.     private void PlayAudioClip(AudioClip audioClip)
    69.     {
    70.         if (audioClip == null) return;
    71.         var audioSource = GetComponentInParent<AudioSource>();
    72.         if (audioSource == null)
    73.         {
    74.             if (transform.parent == null)
    75.             {
    76.                 AudioSource.PlayClipAtPoint(audioClip, FindObjectOfType<SmoothMouseLook>().transform.position);
    77.                 return;
    78.             }
    79.             audioSource = transform.parent.gameObject.AddComponent<AudioSource>();
    80.         }
    81.         audioSource.spatialBlend = 0f;
    82.         audioSource.PlayOneShot(audioClip);
    83.     }
    84. }
    85.  
     
  8. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    Spider Boss Phase Spawner

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3. using UnityEngine.UI;
    4. using UnityEngine.AI;
    5. using System.Collections;
    6. using UnityEngine.Events;
    7. using EmeraldAI.Utility;
    8. using EmeraldAI;
    9.  
    10. public class SpiderBoss : MonoBehaviour
    11. {
    12.     public Transform SpawnPoint;
    13.     private Transform myTransform;
    14.     public List<GameObject> SummonCharacters = new List<GameObject>();
    15.     private List<GameObject> myCharacters = new List<GameObject>();
    16.     private int CurrentCompanions = 0;
    17.     public int NumberofWaves = 3;
    18.     private int CurrentWaves = 0;
    19.     public AudioClip StartWaveSoundClip;
    20.     protected int SpiderQueenHealth;
    21.  
    22.     // Start is called before the first frame update
    23.     void Start()
    24.     {
    25.         for (int i = 0; i < SummonCharacters.Count; i++)
    26.         {
    27.             myCharacters.Add(SummonCharacters[i]);
    28.         }
    29.         CurrentCompanions = myCharacters.Count;
    30.     }
    31.  
    32.     // Update is called once per frame
    33.     void Update()
    34.     {
    35.         SpiderQueenHealth  = GameObject.Find("Spider Queen").GetComponent<EmeraldAISystem>().CurrentHealth;
    36.  
    37.         if ((SpiderQueenHealth <= 1500 && SpiderQueenHealth >= 1000) && CurrentWaves == 0)
    38.         {
    39.             if (CurrentCompanions <= myCharacters.Count)
    40.             {
    41.                 for (int i = 0; i < myCharacters.Count; i++)
    42.                 {
    43.                     Vector3 SpawnPosition = SpawnPoint.transform.position + SpawnPoint.transform.forward * 5 + (Random.insideUnitSphere * 2);
    44.                     SpawnPosition.y = SpawnPoint.transform.position.y;
    45.                     GameObject SpawnedAI = EmeraldAIObjectPool.Spawn(SummonCharacters[i], SpawnPosition, Quaternion.identity);
    46.  
    47.                     //Set an event on the created AI to remove the AI on death
    48.                     SpawnedAI.GetComponent<EmeraldAISystem>().DeathEvent.AddListener(() => { RemoveAI(); });
    49.                     CurrentCompanions++;
    50.                 }              
    51.  
    52.                 PlayAudioClip(StartWaveSoundClip);
    53.                 CurrentWaves++;
    54.              
    55.             }
    56.         }
    57.            else if((SpiderQueenHealth <= 1000 && SpiderQueenHealth >= 500) && CurrentWaves == 1)
    58.             {
    59.             if (CurrentCompanions <= myCharacters.Count)
    60.             {
    61.                 for (int i = 0; i < myCharacters.Count; i++)
    62.                 {
    63.                     Vector3 SpawnPosition = SpawnPoint.transform.position + SpawnPoint.transform.forward * 5 + (Random.insideUnitSphere * 2);
    64.                     SpawnPosition.y = SpawnPoint.transform.position.y;
    65.                     GameObject SpawnedAI = EmeraldAIObjectPool.Spawn(SummonCharacters[i], SpawnPosition, Quaternion.identity);
    66.  
    67.                     //Set an event on the created AI to remove the AI on death
    68.                     SpawnedAI.GetComponent<EmeraldAISystem>().DeathEvent.AddListener(() => { RemoveAI(); });
    69.                     CurrentCompanions++;
    70.  
    71.  
    72.                 }
    73.                 PlayAudioClip(StartWaveSoundClip);
    74.                 CurrentWaves++;
    75.             }
    76.  
    77.             else if((SpiderQueenHealth <= 500 && SpiderQueenHealth >= 0) && CurrentWaves == 2)
    78.             {
    79.                 for (int i = 0; i < myCharacters.Count; i++)
    80.                 {
    81.                     Vector3 SpawnPosition = SpawnPoint.transform.position + SpawnPoint.transform.forward * 5 + (Random.insideUnitSphere * 2);
    82.                     SpawnPosition.y = SpawnPoint.transform.position.y;
    83.                     GameObject SpawnedAI = EmeraldAIObjectPool.Spawn(SummonCharacters[i], SpawnPosition, Quaternion.identity);
    84.  
    85.                     //Set an event on the created AI to remove the AI on death
    86.                     SpawnedAI.GetComponent<EmeraldAISystem>().DeathEvent.AddListener(() => { RemoveAI(); });
    87.                     CurrentCompanions++;
    88.  
    89.                 }
    90.                 PlayAudioClip(StartWaveSoundClip);
    91.                 CurrentWaves++;
    92.             }
    93.         }
    94.  
    95.     }
    96.  
    97.     public void RemoveAI()
    98.     {
    99.         CurrentCompanions--;
    100.     }
    101.  
    102.     private void PlayAudioClip(AudioClip audioClip)
    103.     {
    104.         if (audioClip == null) return;
    105.         var audioSource = GetComponentInParent<AudioSource>();
    106.         if (audioSource == null)
    107.         {
    108.             if (transform.parent == null)
    109.             {
    110.                 AudioSource.PlayClipAtPoint(audioClip, FindObjectOfType<SmoothMouseLook>().transform.position);
    111.                 return;
    112.             }
    113.             audioSource = transform.parent.gameObject.AddComponent<AudioSource>();
    114.         }
    115.         audioSource.spatialBlend = 0f;
    116.         audioSource.PlayOneShot(audioClip);
    117.     }
    118. }
    119.  
     
  9. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    NPC Healer that heals my FPS Controller

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3. using UnityEngine.UI;
    4. using UnityEngine.AI;
    5. using System.Collections;
    6. using UnityEngine.Events;
    7. using EmeraldAI.Utility;
    8. using PixelCrushers.DialogueSystem;
    9.  
    10.  
    11. namespace EmeraldAI
    12. {
    13.  
    14.     [RequireComponent(typeof(BoxCollider))]
    15.     [RequireComponent(typeof(NavMeshAgent))]
    16.     [RequireComponent(typeof(AudioSource))]
    17.     [RequireComponent(typeof(EmeraldAIDetection))]
    18.     [RequireComponent(typeof(EmeraldAIInitializer))]
    19.     [RequireComponent(typeof(EmeraldAIBehaviors))]
    20.     [RequireComponent(typeof(EmeraldAIEventsManager))]
    21.     [SelectionBase]
    22.  
    23.  
    24.     public class NPCHealer : MonoBehaviour
    25.     {
    26.  
    27.         //Support Abilities
    28.         public EmeraldAIAbility m_EmeraldAIAbility;
    29.  
    30.         //public UnityEvent OnHealEventNPC;
    31.         protected static GameObject ObjectPool;
    32.  
    33.         public GameObject SpawnEffect;
    34.         //public List<AudioClip> SpawnEffectSounds;
    35.      
    36.         public AudioClip[] SpawnEffectSound;
    37.         //public AudioClip SpawnEffectSound;
    38.  
    39.         //Healing Cooldown Items
    40.         protected Coroutine HealingOverTimeCoroutine;
    41.         protected int HealthPercentageToHeal = 30;
    42.         protected bool HealingCooldownActive = false;
    43.         public int HealingCooldownSeconds = 8;
    44.         float HealingCooldownTimer;
    45.         protected int CurrentHealth;
    46.         protected int StartingHealth = 15;
    47.         public int AmountToHeal;
    48.        
    49.  
    50.         protected EmeraldAIInitializer EmeraldInitializerComponent ;
    51.         protected EmeraldAIEventsManager EmeraldEventsManagerComponent;
    52.         protected EmeraldAIBehaviors EmeraldBehaviorsComponent;
    53.  
    54.         //RFPS Variables
    55.         private FPSPlayer fpsPlayer = null;
    56.         protected float healthToAdd;
    57.  
    58.  
    59.  
    60.  
    61.         // Start is called before the first frame update
    62.         void Start()
    63.         {
    64.             EmeraldInitializerComponent = GetComponent<EmeraldAIInitializer>();
    65.             EmeraldInitializerComponent.Initialize();
    66.         }
    67.  
    68.         // Update is called once per frame
    69.         void Update()
    70.         {
    71.             //Healing cool down to avoid an AI healing too often
    72.             if (HealingCooldownActive)
    73.             {
    74.                 HealingCooldownTimer += Time.deltaTime;
    75.  
    76.                 if (HealingCooldownTimer >= HealingCooldownSeconds)
    77.                 {
    78.                     HealingCooldownTimer = 0;
    79.                     HealingCooldownActive = false;                  
    80.                 }
    81.             }
    82.             else
    83.             {
    84.                 FindPlayer();
    85.                 if (fpsPlayer.hitPoints < 100)
    86.                 {
    87.                  
    88.                     Heals();
    89.                 }
    90.             }
    91.  
    92.         }
    93.  
    94.         private void FindPlayer()
    95.         {
    96.             if (fpsPlayer == null)
    97.             {
    98.                 fpsPlayer = FindObjectOfType<FPSPlayer>();
    99.             }
    100.         }
    101.  
    102.         public void Heals()
    103.         {
    104.            
    105.            PlayAudioClip(SpawnEffectSound[Random.Range(0, SpawnEffectSound.Length)]);
    106.             GameObject.Find("Bcoles").GetComponent<EmeraldAISystem>().EmeraldEventsManagerComponent.PlayEmoteAnimation(1);
    107.             GameObject.Find("Bcoles").GetComponent<EmeraldAISystem>().EmeraldEventsManagerComponent.SpawnAdditionalEffect(SpawnEffect);
    108.             FindPlayer();
    109.             fpsPlayer.HealPlayer(Mathf.Min(AmountToHeal, fpsPlayer.maximumHitPoints - fpsPlayer.hitPoints));
    110.  
    111.             HealingCooldownSeconds = m_EmeraldAIAbility.AbilityCooldown;
    112.             HealingCooldownTimer = 0;
    113.             HealingCooldownActive = true;
    114.  
    115.         }
    116.  
    117.         private void PlayAudioClip(AudioClip audioClip)
    118.         {
    119.             if (audioClip == null) return;
    120.             var audioSource = GetComponentInParent<AudioSource>();
    121.             if (audioSource == null)
    122.             {
    123.                 if (transform.parent == null)
    124.                 {
    125.                     AudioSource.PlayClipAtPoint(audioClip, FindObjectOfType<SmoothMouseLook>().transform.position);
    126.                     return;
    127.                 }
    128.                 audioSource = transform.parent.gameObject.AddComponent<AudioSource>();
    129.             }
    130.             audioSource.spatialBlend = 0f;
    131.             audioSource.PlayOneShot(audioClip);
    132.         }
    133.     }
    134.        
    135.     }
     
  10. Anoa

    Anoa

    Joined:
    Apr 1, 2016
    Posts:
    9
    Hello, is there a way to make support ability to heal friendly AI?
     
  11. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Hi will this work with A star pathfinding Pro?
     
  12. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    Untiy navmesh only to my knowledge
     
  13. Grzegorz_Kwasniewski

    Grzegorz_Kwasniewski

    Joined:
    Feb 4, 2016
    Posts:
    9
    Thanks for the advice, but I have already done that. Capsule positioner is set around the player's head, but AI still shoots for the legs.
     
  14. itsmikeski

    itsmikeski

    Joined:
    Nov 25, 2021
    Posts:
    5
    I'd like to create a spider that can walk up walls and the ceiling and rotate. Ive created the navmesh properly and set links etc, so that's not the problem, but my AI character keeps wanting to align itself to the Player when it detects it. It also wont wonder when rotated and placed on a wall. Any ideas?
     
  15. Gaffe

    Gaffe

    Joined:
    Jul 13, 2017
    Posts:
    5
    edited: Nevermind I thought there was a bug but it I just had some detection settings set up wrong. I had an agent only responding to hits, and not detecting on their own due to setting the wrong tag/layer. Due to only responding to hits, being attacked by multiple enemies caused some confusion when the targeted enemy died.

    Enjoying the asset very much! Happy holidays!
     
    Last edited: Dec 23, 2021
  16. m0ds84

    m0ds84

    Joined:
    May 25, 2016
    Posts:
    18
    Hi there, I've had a mostly smooth setup (RFPS, don't judge!). But when the ragdoll is supposed to be triggered after taking damage, I get this error. It occurs on your example AI's (Chomper, Spitter) as well as the ones I've set up:

    EmeraldAI.Utility.EmeraldAIInitializer.RagdollDeath () (at Assets/Emerald AI/Scripts/Components/EmeraldAIInitializer.cs:1517)

    Line 1517 is the following (i haven't had any bright ideas yet..)

    Code (CSharp):
    1. EmeraldComponent.RagdollTransform.GetComponent<Rigidbody>().AddForce((EmeraldComponent.EmeraldEventsManagerComponent.GetAttacker().position - transform.position).normalized * -EmeraldComponent.ReceivedRagdollForceAmount, ForceMode.Impulse);
    Ragdoll works normally before I add Emerald AI. When it produces that error the characters just freeze position and loop their last animation. Animation death works fine but I want ragdoll deaths so not sure how to proceed. Advice appreciated, thanks!
     
    Last edited: Dec 25, 2021
  17. Grzegorz_Kwasniewski

    Grzegorz_Kwasniewski

    Joined:
    Feb 4, 2016
    Posts:
    9
    Hi all,
    is there a tutorial on how to set up AI shooting bullet with series, like on this video?



    I can't seem to get it to work for Emerald 3.0. My AI always shoots only one bullet and after that, it needs to take a short break.
     
  18. Ben2390

    Ben2390

    Joined:
    Sep 6, 2014
    Posts:
    11
    I'm pretty sure this would have been done by having several EmeraldAttackEvents on the same animation.
     
  19. Grzegorz_Kwasniewski

    Grzegorz_Kwasniewski

    Joined:
    Feb 4, 2016
    Posts:
    9
    Thank you :) That worked for me.
     
  20. ml785

    ml785

    Joined:
    Dec 20, 2018
    Posts:
    119
    On the documentation it suggests to look at Example Scenes (https://github.com/Black-Horizon-Studios/Emerald-AI/wiki/Example-Scenes) but I don't see them after importing Emerald AI into my project. For example, the "AI vs AI" scene. Is there something I'm missing or were these example scenes phased out for 3.0? I see the "Demo Scenes" folder of course. Thanks.

    Edit: I was looking at the Wiki documentation linked on the 3.0 Asset Store page, whereas a different offline documentation is included in the 3.0 package. But the documentation in the 3.0 package lists Example Scenes that I still do not see in the actual package's 'Demo Scenes' folder. It is not a very big deal lol it is just confusing.
     
    Last edited: Jan 3, 2022
  21. Darrkbeast

    Darrkbeast

    Joined:
    Mar 26, 2013
    Posts:
    125
    Hi, I got that bug to, if I shoot the enemy before the enemy detects player it will target player but not set the target type. Adding the setdetected works for me too.
     
  22. heddesheimer

    heddesheimer

    Joined:
    Oct 23, 2019
    Posts:
    4
    I have a problem: I want to set up an animal as a companion. According to the Docs, there should be an example, but I cannot find it.
    It says in the Editor, I should use the public function SetTarget, but I'm totally stuck because I cannot find out how I can set the Target to the player GameObject. I managed to let my animal follow the player by using the NavMesh agent, but it seems the animation is not playing correctly. When the animal turns left or right, it already plays the regular walk animation instead.
    What am I missing here?
     
  23. Harald_Heide

    Harald_Heide

    Joined:
    Jul 22, 2015
    Posts:
    81
    Feeling very kind hearted today and sharing FlyCamera script upgraded to unity new input system (easy way):
    FlyCamera.cs:
    using UnityEngine;
    using System.Collections;
    using UnityEngine.InputSystem;
    namespace EmeraldAI.Example
    {
    public class FlyCamera : MonoBehaviour
    {
    public float mainSpeed = 10.0f;
    public float shiftAdd = 25.0f;
    public float maxShift = 25.0f;
    public float camSens = 0.25f;
    private Vector3 lastMouse = new Vector3(255, 255, 255);
    private float totalRun = 1.0f;
    void Update()
    {
    if (Mouse.current.rightButton.wasPressedThisFrame)
    {
    lastMouse = Mouse.current.position.ReadValue();
    }
    if (Mouse.current.rightButton.isPressed)
    {
    Vector3 _v3 = Mouse.current.position.ReadValue();
    lastMouse = _v3 - lastMouse;
    lastMouse = new Vector3(-lastMouse.y * camSens, lastMouse.x * camSens, 0);
    lastMouse = new Vector3(transform.eulerAngles.x + lastMouse.x, transform.eulerAngles.y + lastMouse.y, 0);
    transform.eulerAngles = lastMouse;
    lastMouse = Mouse.current.position.ReadValue();
    }
    //Keyboard commands
    Vector3 p = GetBaseInput();
    if (Keyboard.current.leftShiftKey.wasPressedThisFrame)//(Input.GetKey(KeyCode.LeftShift))
    {
    totalRun += Time.deltaTime;
    p = p * totalRun * shiftAdd;
    p.x = Mathf.Clamp(p.x, -maxShift, maxShift);
    p.y = Mathf.Clamp(p.y, -maxShift, maxShift);
    p.z = Mathf.Clamp(p.z, -maxShift, maxShift);
    }
    else
    {
    totalRun = Mathf.Clamp(totalRun * 0.5f, 1f, 1000f);
    p = p * mainSpeed;
    }
    p = p * Time.deltaTime;
    transform.Translate(p);
    }
    private Vector3 GetBaseInput()
    {
    Vector3 p_Velocity = new Vector3();
    if (Keyboard.current.wKey.isPressed)//(Input.GetKey(KeyCode.W))
    {
    p_Velocity += new Vector3(0, 0, 1);
    }
    if (Keyboard.current.sKey.isPressed)
    {
    p_Velocity += new Vector3(0, 0, -1);
    }
    if (Keyboard.current.aKey.isPressed)
    {
    p_Velocity += new Vector3(-1, 0, 0);
    }
    if (Keyboard.current.dKey.isPressed)
    {
    p_Velocity += new Vector3(1, 0, 0);
    }
    if (Keyboard.current.qKey.isPressed)
    {
    p_Velocity += new Vector3(0, 1, 0);
    }
    if (Keyboard.current.eKey.isPressed)
    {
    p_Velocity += new Vector3(0, -1, 0);
    }
    return p_Velocity;
    }
    }
    }
     
    Last edited: Jan 10, 2022
  24. heddesheimer

    heddesheimer

    Joined:
    Oct 23, 2019
    Posts:
    4
    Another problem with the AI 3.0 script: The agent is following my player, but only at a slow pace (speed is never higher than 2.0). I want the animal run towards the player at a higher speed, but even when I set agent.speed = 20f; and agent.acceleration = 20f; nothing changes.
    How can I change the animals speed? I want the animal to run towards the player when the distance is high, and walk if the distance becomes lower.
     
  25. Harald_Heide

    Harald_Heide

    Joined:
    Jul 22, 2015
    Posts:
    81
    Is there a way to use transition animations like for instance between idle states: laying and standing (Trans laying to stand and back). I'm using a GIM fox at the moment. Tried to update directly in the animation override controller but to me it looks like Emerald is calling the animations directly instead of using the controlling variables in the anim override controller. Any suggestions? Would greatly improve animation esthetics if it would work.
     
  26. f8f82009

    f8f82009

    Joined:
    Nov 29, 2020
    Posts:
    6
    I need help
    Do you know what the problem is when I do a magic attack using particles
    And use the vObjectDamage script to merge
    But it does not damage the emerald monster.
    Note that I have used the integration between Invector and Emerald completely and there is no shortage
    Everything works fine except the attack with particles, he doesn't know with the emerald
    But it works with other tools
     
  27. f8f82009

    f8f82009

    Joined:
    Nov 29, 2020
    Posts:
    6
  28. reinaldf

    reinaldf

    Joined:
    Nov 24, 2017
    Posts:
    5
    Is there a way to create a timer when player is out of sight of the enemy ai? That once player is out of sight of enemy of a certain amount of time, it will stop looking for player?
     
  29. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    315
    I don't think there is one built in, no. Would make a great feature though, for stealth games and such.
     
  30. NEPS

    NEPS

    Joined:
    Jul 8, 2015
    Posts:
    13
    Hi, using Unity 2020.3.2 and Emerald 3.0 I see that was recently updated. Now for some reason when setting up new characters I am unable to add attack animations, even when they have been setup correctly with EmeraldAttackEvent, etc. Any reason for this or change ?
     
  31. Andrew203

    Andrew203

    Joined:
    Apr 23, 2018
    Posts:
    43
    Hey, can anyone tell me if in Emerald AI 3.0 you need to fill all animations in order for AI to work like in 2.0? For example turning left and right etc.
    I need to create simple AI for casual game.
     
  32. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    I’m not quite sure what you mean. Can you please provide a screenshot of your issue? Nothing was changed other than what was stated in the 3.1.1 release notes.
     
  33. BHS

    BHS

    Joined:
    Dec 21, 2009
    Posts:
    4,760
    You can use idle or walk animations in place of turn animations. You can also use walk or run straight animations in place of walk left, run left, etc. There’s also an option to enable Non-Combat AI so you don’t have to apply any combat animations, if desired.
     
  34. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    92
    Is there a behavior to make ai run away from a specific tag? Like making it so once the player is low on health the ai are set to avoid the player instead of chasing them. Is there a way to set tag avoidance in code?

    Also how does the run attack work? Does emerald ai animate the legs and body separately and blend the attack and running animation? If not do we specifically need a running attack animation?
     
    Last edited: Jan 22, 2022
  35. zenman3119

    zenman3119

    Joined:
    Nov 24, 2013
    Posts:
    6
    I created an AI enemy and it worked fine. I duplicated it and only changed some of the sub meshes to create a variation of the character and received the error on the duplicate. Unity 2021.2.7f1 - EmeraldAI 3.1.1

    This returns null only on the duplicate all others in scene work correctly.
    "GetComponentInChildren<VisibilityCheck>().EmeraldComponent = GetComponentInChildren<EmeraldAISystem>();"

    NullReferenceException: Object reference not set to an instance of an object
    EmeraldAI.Utility.EmeraldAIInitializer.SetupOptimizationSettings () (at Assets/Emerald AI/Scripts/Components/EmeraldAIInitializer.cs:179)
    EmeraldAI.Utility.EmeraldAIInitializer.Initialize () (at Assets/Emerald AI/Scripts/Components/EmeraldAIInitializer.cs:20)
    EmeraldAI.EmeraldAISystem.Awake () (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:896)
     
    Last edited: Jan 23, 2022
  36. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    @BHS when are the updates from the poll above coming out?
     
  37. f8f82009

    f8f82009

    Joined:
    Nov 29, 2020
    Posts:
    6
    I use invector When I attack Suddenly the game mode stops This problem appears in the report list

    NullReferenceException: Object reference not set to an instance of an object
    EmeraldAI.Utility.EmeraldAIDetection.SetDetectedTarget (UnityEngine.Transform DetectedTarget) (at Assets/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:802)
    EmeraldAI.EmeraldAISystem.Damage (System.Int32 DamageAmount, System.Nullable`1[T] TypeOfTarget, UnityEngine.Transform AttackerTransform, System.Int32 RagdollForce, System.Boolean CriticalHit) (at Assets/Emerald AI/Scripts/System/EmeraldAISystem.cs:2252)
    Invector.vShooter.vProjectileControl.Update () (at Assets/Invector-3rdPersonController/Shooter/Scripts/Weapon/vProjectileControl.cs:84)
     

    Attached Files:

  38. timerace

    timerace

    Joined:
    Feb 27, 2019
    Posts:
    27
    Hello
    @BHS will there be an ai jump feature, so they can follow precisely?
     
  39. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    Just thought I should say I use Invector, and I have not seen this.
     
  40. SI_007

    SI_007

    Joined:
    Aug 10, 2015
    Posts:
    84
    Hi There @BHS

    I would like to know what would be considered a "best practice" for adding animations to the EmeraldAI animation controller?

    For example, let's say I have a 20 animations related to the AI eating at a table. Which approach would you recommend, animation controller wise?

    Thanks!
    Pascal
     
  41. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    You would either use emotes or use the events and write your own interactions with c#
     
  42. SI_007

    SI_007

    Joined:
    Aug 10, 2015
    Posts:
    84
    Thanks SickaGamer!
    I've just re-read the documentation, it does make perfect sense to use the emotes for such additional animations.
     
  43. SI_007

    SI_007

    Joined:
    Aug 10, 2015
    Posts:
    84
    However, I noticed that there is a limit of 10 emote animations. Would it be possible to remove this limit?
     
  44. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    If you write your own script, you can do whatever you want with the events.
     
  45. bloodymastah

    bloodymastah

    Joined:
    Jan 28, 2022
    Posts:
    1
    hey , i have 1 problem , in the emerald there is option for COMBAT HIT ANIMATION when ai recives damage when in combat or not in combat. I put both animations but it does not play it when i hit ai. why is that ?
     
  46. f8f82009

    f8f82009

    Joined:
    Nov 29, 2020
    Posts:
    6
    Thank U
     
    wood333 likes this.
  47. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    The AIinitializer has suddenly lost its mind. It claims all my Emerald NPCs attack animations are lacking an EmeraldAttackEvent, in red lettered debug notations in the console. Yet, all my attack animations have the requisite event.:(
     
    Last edited: Feb 17, 2022
  48. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,269
    @BHS you still here?!
     
  49. unity_B57BC6306274C79F026A

    unity_B57BC6306274C79F026A

    Joined:
    Apr 8, 2021
    Posts:
    12
    Hi, I bought the Emerald AI 3.0 asset but when I try to change the parameters of the Emerald AI System Script associated with a game obiecy it is impossible to make any changes because the screen with the various items is not displayed correctly. Thus the program is unusable.

    Wait for an answer from the developers

    Mauro Screeshot Emerald AI 3.0 issue.jpg
     
  50. MaximilianPs

    MaximilianPs

    Joined:
    Nov 7, 2011
    Posts:
    321
    Would be nice to have an RPG Kit integration...
    Even if I guess I can workaround it by my self :D

    [Edit]
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using UnityEngine;
    5. using UnityEngine.AI;
    6. using UnityEngine.Audio;
    7. using UnityEngine.UI;
    8.  
    9. namespace DevionGames.StatSystem
    10. {
    11.     public class StatsHandler : MonoBehaviour, IJsonSerializable
    12.     {
    For some reason I can't add using EmeraldAI.... to this class.
    Can somebody help me?
     
    Last edited: Feb 14, 2022