A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'Assets and Asset Store' started by BHS, Jun 26, 2015.
Has anyone used Emerald AI with Core GameKit?
Yes, I use it with Core GameKit. You are probably concerned with pooling issues. I've personally had to add some additional code in order to make it work smoothly. The main thing was to create a new class that had references to all the Emerald classes like EmeraldAISystem, EmeraldAIInitializer, etc, and I have them disabled in the prefab. Then in an OnSpawned() function I enable them. I might have had to do some other things, but I don't remember all the details. But if you have a specific problem I'm sure I could help you find a way to make it work.
@magique I'm guessing it's a pooling issue. The AI is moving to the spawn point regardless where it's positioned. I made a earlier post about it. https://forum.unity.com/threads/rel...lls-blocking-more.336521/page-68#post-4648387
I saw that post, but I admit that I don't quite understand what you're saying. In your post, you state the following:
"I'm using Core GameKit to spawn groups of enemies in the scene. But all the AI will move to one location instead of the spawner location"
Do you mean that the AI are not spawning in their defined spawn positions? What do you mean by moving to one location? What location? Are the AI supposed to spawn in random positions and then wander? More details would help.
Spawn B AI moves towards Spawn A.
Odd. When I run the demo, the 2 groups of spawns just stay around their respective spawn points and don't move anywhere.
If you start killing AI from Spawn B they will start moving.
OK. I had killed some from spawn A and nothing unusual happened. I will try going to spawn b.
OK, so a couple of things. If I walk toward the spawn B AI without the sword up until they notice me and then turn around and go back for the sword, then those AI start moving toward spawn point B If they notice me again (line of sight method?) then they will stop moving toward A and head for me. However, if I get the sword and go attack them then I just fight them all and they never go to A.
Is there any chance that your spawn point has a layer that the enemy might be detecting? Or that the AI are detecting each other's layers? I don't see how this is a Core Gamekit issue.
I checked the layers for the LevelWaveSettings prefab in the scene and everything is set to Default. I'm using the demo AI from Emerald AI; the Forest Golem and Fallen Guardian.
Not the prefab, but the actual spawn points in the scene. Also, I can't check the forest golem and fallen guardian details so you'll need to check the detection layers and see what they are detecting. Also, might want to check their factions as well.
The AI is detection Character and the layers of the spawners are default.
OK, so it seems like it's all OK. I am no longer home so I can't help at the moment. What happens if you move spawn point A somewhere else? Does it still go to the new location? And if you turn off Spawn Point A completely, does it still go to where it was?
@magique I have tried moving the spawners to a different location and clear the AI to respawn but they are still going to the same location. I think it's something in the code.
OK, so the AI go to the position where Spawn Point A used to be even though it's not there anymore? If so, then there is definitely something odd going on and not related to Core GameKit for sure.
I've reached out to the developer and I'm still waiting for a response. If they can get me a copy of the asset, I will make an integration tutorial for it.
You will need a reference to the object you would like to interact with. Once you have this, you would call:
There are also quite a few included example scripts that should give you a good idea on how to create custom scripts that alter an AI's variables.
What wander type are you using? If you are using destination, and your AI are prefabs, they will all move to the same destination that was set by the prefab. If you aren't using it, I would recommend using the Stationary destination type. This allows the AI to stay stationary where they're spawned and will only move if a target gets within distance. Another option is the dynamic wader type. This allows AI to generate their own waypoints based on their current location.
What wander type are you using?
Strange, I'm not sure. I haven't encountered this yet, but I will look into this to see if I can recreate it.
No ETA yet, but I'm hoping to have it released as soon as possible.
Strange, even if the AI is in front of the player, it should flee in the opposite direction. I will look into this and fix it with the next update if there's an issue.
You can damage an AI with something like this:
void OnCollisionEnter(Collision C)
if (C.gameObject.tag == YourEmeraldAITag)
if (C.gameObject.GetComponent<EmeraldAISystem>() != null)
C.gameObject.GetComponent<EmeraldAISystem>().Damage(YourDamageAmount, EmeraldAISystem.TargetType.Player, YourPlayerTransform, YourRagdollPushAmount);
As for fleeing from a projectile, you could do something similar and have the AI flee from the projectile using a trigger collider:
void OnTriggerEnter(Collider C)
if (C.gameObject.tag == YourEmeraldAITag)
if (C.gameObject.GetComponent<EmeraldAISystem>() != null)
C.gameObject.GetComponent<EmeraldAISystem>().Damage(YourDamageAmount, EmeraldAISystem.TargetType.NonAITarget, transform, 0);
I have plans to add networking support and Mirror is one of the asset I plan to integrate, but it will be a couple of months.
@BHS In a future update could we get an option for the AI to stop chasing when the player has left their line of sight for a set period of time? Currently (as far as I know) we can only get them to stop chasing when the player exceeds the chase distance, which is obviously limiting for game scenarios set in small or indoors environments. The only way around it is by manually altering the AI state or clearing targets e.g. on entering a trigger, which is obviously not ideal.
Hi @BHS is there built in functionality for the AI to detect what object they are colliding with, and do an action? For example, walk into a door trigger, then AI runs an event/animation etc to open it. Or collides with a small wall, and can climb over it. I've not used the current release yet, waiting for 2.3
How can i achieve ragdoll like in video. Plz help
Create a ragdoll on your character with the ragdoll wizard then in the combat tab under the combat settings there will be a dropdown that says either ragdoll or animation. Choose ragdoll.
Does emerald AI support creatures that are water/land creatures?
I am using waypoint as wander type. And I tried it with both humanoid and non humanoid rid. Its the same. Do I waypoints have some kind of radius?
Also, some of my AI move on my terrain but some of them do nothing, then when i have it in playmode and move them, they literally go back to their spot for some reason?
That's a great idea. I will try to add this feature as soon as possible.
Not currently, but that's a great idea. I'll add this to the list of features to add.
Not currently as Emerald AI uses Unity's NavMesh. I have plans to add water/swimming support with a future update though.
Thanks. Would certainly make AI more realistic in their actions. List of possibilities would be endless...
Target based events would be good too (event after target acquired, event after target lost, event after target is killed by this AI, event after target is killed by another AI, event after target is killed by this AI team number) - that sort of thing.
Sorry for that reply, but i need your help. I am in dead end now and actually dont know what to do.
How can I resurrect AI after death?
I use the object pool manager, and after death (deactivation) and the subsequent revival (activation), the AI behaves very strangely.
I also tried a "ResetAI();" function, but this is doesn't work.
Yeah, was wondering as i can only have 5 factions and i have many types of wildlife. Was also wondering if there was gonna be any feature to do with hunger and thirst. I don't mind doing one, if you are planning one. I might be able to help with it!
There's currently a bug with AI being properly reset as the AI's default state is not set when the ResetAI function is called. This can be fixed by calling EmeraldAIBehaviors.DefaultState(); after calling the ResetAI function.
I plan on adding more factions within the next couple of updates. I don't have plans for hunger and thirst, but they are good suggestions. I can certainly consider adding them to a future update.
EmeraldAI is really good and works as expected when using through GUI but I find that GUI is too limited and it's hard to extend through the code. I hope it becomes more customizable by exposing APIs and such. If so, I can perhaps make it callable from external tools such as NodeCanvas.
Please keep the good work.
For those who'd like to damage an AI using PlayerMaker, I've figured out how to do so.
1) Open up the EmeraldAISystem script and find the Damage function. For some reason, TargetType? TypeOfTarget = null does not play nicely with PlayMaker so you will need to make this change (I will add a function specifically for PlayMaker with the 2.2.2 update):
public void Damage (int DamageAmount, TargetType? TypeOfTarget = null, Transform AttackerTransform = null, int RagdollForce = 100)
public void Damage (int DamageAmount, TargetType TypeOfTarget, Transform AttackerTransform = null, int RagdollForce = 100)
2) After creating your PlayMaker object, create 2 states; Detection, Get Component, and Damage. Next, create 2 variables; one EmeraldAISystem variable (this will be used to store the detected EmeraldAISystem component) and one GameObject called Target (this will be used to store the detected object)
3) You will need some way of detecting the target you would like to damage. For this example, I used a Trigger Event and stored the collider object as a new variable called Target (you will need to have a collider on your object and its Is Trigger set to true). You will want to make sure that the tag is set to your Emerald AI Unity Tag. You will need to transition to your Get Component state once you've created it.
3) Using a the Target object, get the EmeraldAISystem component using your EmeraldAISystem object you created to store it. Create a Send Event action to transition to the Damage state.
4) Create a Call Method and use the EmeraldAISystem object. This should allow you to select the Damage as the Method. Once you've done this, you will be able to set the Damage Amount, Target Type, Attacker Transform (which should be your PlayMaker object), and Ragdoll Force.
A very similar technique can be used to alter the AI's behavior (using the EmeraldAIBehaviors script) and the an AI's event manager (using EmeraldAIEventsManager script).
Any updates coming to Emerald
Ok, so as for hunger and thirst if i got a solution, i'll be the first to give you the information!
I have an EmeraldAI + CTS(Complete Terrain Shader) setup and I can't get my EmeraldAI to spawn on the designated terrain texture. I've been trying to solve this for a couple weeks now, any help?
I've tried disabling 'Strip textures' within CTS but no luck? What am I missing here?
This errors always show in Console when i spawn enemies with this command:
Instantiate(slowZombies[Random.Range(0, slowZombies.Length)], spawnPoints[Random.Range(0, spawnPoints.Length)].position, transform.rotation);
NullReferenceException: Object reference not set to an instance of an object
EmeraldAI.EmeraldAIBehaviors.ActivateCombatState () (at Assets/!ASSETSTOREKITS/Emerald AI/Scripts/Components/EmeraldAIBehaviors.cs:476)
EmeraldAI.Utility.EmeraldAIDetection.DetectTarget (UnityEngine.GameObject C) (at Assets/!ASSETSTOREKITS/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:164)
EmeraldAI.Utility.EmeraldAIDetection.OnTriggerEnter (UnityEngine.Collider C) (at Assets/!ASSETSTOREKITS/Emerald AI/Scripts/Components/EmeraldAIDetection.cs:398)
What can be a problem?
I looked at one of the reviews and someone said the AI doesn't respond to sound. Is this true? It seems like the first thing an AI system would put in place. What is the real story?
@jnbbender Emerald is not responsible for your weapons and sound FX. Do you see a lot of other AI systems providing hearing simulation? I know that ICE-Creature Control had a simple hearing implementation that was in essence a copy of its vision simulation with a larger arc, but ICE is no more.
Sound detection is an advanced function (I hope it evolves into Emerald) that typically relies on integration with whatever is generating the sound. This is usually the weapons that the character is using. Each weapon will require a script that defines its sound range, potentially a physics sphere to cast for detection, and this can be extended to each object/entity in a level having an acoustic property (how well it allows, muffles, or blocks sound propagation), perhaps based on materials or tags. All of this equals overhead.
The AI would then need yet another physics sphere to define its hearing range. If the originating object's sound range overlaps the detecting object's hearing range, and the objects in between don't cancel the sound, you have detection. There are a lot of dependencies.
I'm doing it myself, but it is rudimentary. It doesn't consider anything between the originator and listener. No acoustics for echo or damping. I create a noise.cs script which watches the active weapon's audio source, and if isPlaying, sets the sound travel distance and checks for an AI hearing collider in range. Grenade goes off 50 units away, AI "hears" it. 5 x 1 unit walls in between player and AI? Doesn't matter. 50.1 units away? Nope, can't hear it. Not realistic, but it's just a game...
Is there some reason Emerald creatures use a box collider rather than capsule?
So I've used Emerald on some past AI characters without issues. I have one new character I'm trying it on, that is having an issue. This character is rigged, but didn't have any existing animations. As soon as I created AI controller with Emerald, it correctly follows my player around, but it seems to have sunk below ground level and just moves around below ground level without any combat maneuvers or similar. Am I missing something?
Whenever I see this, it usually turns out that the animator controller doesn't have the creature's avatar assigned.
That definitely seemed to improve things.
I am seeing a new issue though that's perplexing. So I changed the Animation Controller to be the stock Third Person Animator Controller (from Unity Standard Assets). Is there a conflict with Emerald and that controller? Whenever i go in the Animations tab and select a 'walk' animation, I immediately get a 'IndexOutofRangeException: Index was outside the bounds of the array'. Subsequently, the Animations tab disappears, and I can't adjust it. So I have to shutdown Unity, and no matter what animation I insert into that slot, I get that 'IndexOutofRange' Exception again.