Search Unity

[UPDATED] ICECreatureControl v1.4.0 - creature AI for enemies, animals, monsters, zombies ...

Discussion in 'Assets and Asset Store' started by icetec, Aug 11, 2015.

  1. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I agree.
    Brute common coding is to perform all stuff in update(), instead of considering many process can be done less frequently, it's not necessary for small games, while it is a good practice for bigger ones.
     
  2. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Plenty of options there, including Easy Cull for camera culling (not sure if it works on Unity 2017.x though), ideal for just a large amount of AI as it only searches for them under a specific parent gameObject in one scene, not ideal for large amounts of gameObjects, but you can change pieces of the code to stop AI brains, increasing performance, or just removing the renderer. I don't think you really need Occlusion culling if you have a good stream implementation as really you are only seeing the visible area and maybe tall buildings with LOD.
     
  3. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    You don't have to search for AI if you spawn depending on demand based on player position.
    And you unspawn it when AI leaves it's predefined area.

    Better you could make some Spawner system that would save AI position before unspawning and restore it when the player gets back in the AI area.

    What your game type is ? Tps shooter with animals and AI mob characters on the map ?
    Using pool system of Ice Creatures plugin will work well. The main area you could work on is the level assets with LOD, culling etc ... otherwise i don't see some issue with Ice creatures system as you cna use pooling that manages creatures activation and deactivation for you.

    One option i would add to the plugin is the ability to let us drop some prefabs of any AI type , select them as some AI group , and have their position saved. When you start entering the AI area they are spawned to the right position.
    This can be usefull to make some group of Guard keeping their position in some strategic points for example.

    Anyway, you can dig this tutorial also that is usefull about AI optimisation.
     
    Last edited: Nov 4, 2017
    julianr likes this.
  4. jonfinlay

    jonfinlay

    Joined:
    Aug 25, 2015
    Posts:
    535
    Hey Pit, that UFPS tutorial was great. Cheers for doing that. I was able to it to work fine without needing an adapter, both to inflict and take damage. I was wondering though, is there any way of changing the material of the creature through ICE such as when a creature is wounded, or if a turtle enters the water and comes out with moss on it?

    Also, three possible bugs:
    1. I've tried the options of disabling the collider, destroying it, and disabling impact on the body part that does the damage by setting it in the Events part of the Death behaviour, but when the player walks over the dead animal it still applies damage. Is this a bug? In fact I've just reliased that no events in the Death behaviour seem to work, I tried adding a gas as an Effect to appear when it dies, but it doesn't work either.
    2. When the creature kills the UFPS player, then it keeps looping the killing sound even though the player has respawned somewhere else. I've disabled the looping killing sound for now as a temporary fix though, so not a real issue.
    3. Sometimes, for no apparent reason, the creature doesn't play its death animation when killed, but stays in an idle position.
    Thanks
     
    Last edited: Nov 4, 2017
  5. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Open World as the main game, with small to medium levels for additional gameplay. I currently spawn in AI based on waves and location, it will top up the AI on a specific type if it needs more in the area, or if objectives are not met. When you go out of the area completely it will despawn them, but uses a Pool system, not ICE CC.
     
  6. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    It's up to you ot create clever level design with small hills or structures masking where the AI spawns when you approach a zone, until your level would be very flat and borring lol

    You can still manage virtually any number of AI showing the nearest ones and update less frequently the calculation of the spawned distant ones. Also keep AI spread around and not all moving towards the player at same time until it is some arcade game like Serious Sam.

    Far Cry 4 keeps 20 units max around the player, new reinforcements to some event always spawn in a way the player can't see them (perhaps they multiple spawn points like boths sides of a road).
    And animals ecosystem are always somewhat separated, like main animal category have it's own zone, perhaps you'll find two types of animal in the same zone with one very few number, but most of the time you encounter only one animal type per defined zone.

    Anyway, ICe Creatures could get some addon to manage global spawning around the player, but the plugin can't avoid bad level design about performance if users make many creatures zones too nearest.
     
  7. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Yeah I already do that. I don't like AI that just appear in front of you or from a distance - it's better to have zombies coming out of tunnels, underground/subways/alleys/tombs that sort of thing. Or aliens being teleported in with some particles simulating the teleport after a craft flies in from the atmosphere or a cloaking device, or a drop ship landing and dropping off some troops. Makes it look more professional.
     
    Last edited: Nov 5, 2017
    zenGarden likes this.
  8. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I'm giving 1.4 a try, but I get errors after importing. I'm on Unity 5.6.3p4.

    Assets/ICE/ICECreatureControl/Scripts/Core/Editor/Core/EditorUtilities/ice_creature_editor_objects.cs(1332,35): error CS0117: `EditorTools' does not contain a definition for `IsPrefab'

    Assets/ICE/ICECreatureControl/Scripts/Core/Editor/Core/EditorUtilities/ice_creature_editor_objects.cs(1337,56): error CS0117: `EditorTools' does not contain a definition for `ObjectTitleSuffix'

    Assets/ICE/ICECreatureControl/Scripts/Core/Editor/Core/EditorUtilities/ice_creature_editor_register_groups.cs(218,45): error CS0117: `EditorTools' does not contain a definition for `IsPrefab'

    Assets/ICE/ICECreatureControl/Scripts/Core/Editor/Core/EditorUtilities/ice_creature_editor_register_groups.cs(554,26): error CS0117: `EditorTools' does not contain a definition for `IsPrefab'

    Assets/ICE/ICECreatureControl/Scripts/Core/Editor/Core/EditorUtilities/ice_creature_editor_target.cs(95,37): error CS0117: `EditorTools' does not contain a definition for `IsPrefab'

    Assets/ICE/ICECreatureControl/Scripts/Core/Editor/Core/EditorUtilities/ice_creature_editor_target.cs(141,37): error CS0117: `EditorTools' does not contain a definition for `IsPrefab'

    Assets/ICE/ICECreatureControl/Scripts/Core/Editor/Core/EditorUtilities/ice_creature_editor_target.cs(145,49): error CS0117: `EditorTools' does not contain a definition for `IsPrefab'

    etc.
     
  9. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    Did you first completely remove the old ICE folder? I had errors too, but in the release notes it says you have to delete first. When i did that i had no more errors.
     
  10. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I didn't have an old version in this project.
     
  11. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    But it's doable with very good alpha fading and long enought distance in front of the player, it's not very noticeable
    Another trick is to spawn where the player is not looking like sides or behind, used in MSG 5 game when the horse is spawning lol
     
    julianr likes this.
  12. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    You probably have another asset with editortools class.
     
  13. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    You're right. I didn't spend much time looking at the error, but it makes sense now. Thankfully, it's just one asset with a very small class that I can wrap in a namespace. Thanks.
     
  14. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    bit difficult for multiplayer though ;)
     
  15. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    @icetec

    Pooling in last version have an issue or did i miss something ?

    I defined in creature register a golem character with pooling and 5 max coexistant objects , and i have culling activated for the golem in "creature essentials".
    But in game , each time a golem is culled it's disabled, but new ones get created instead of using the pool system.
     
  16. sylon

    sylon

    Joined:
    Mar 5, 2017
    Posts:
    246
    I encountered the same thing.
     
  17. icetec

    icetec

    Joined:
    Mar 11, 2015
    Posts:
    592
    Hi zenGarden, did you use the same culling values also in the creature-register, while spawning a creature?
     
  18. MrGky93

    MrGky93

    Joined:
    Feb 27, 2014
    Posts:
    281
    No more email support?
    More than 1 week no answer :/
     
  19. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Hi @icetec

    Culling option is only on the creature essential.
    While Creature Register has "Pool" enabled.



    As you can see below , when the player go far culling works but lot of inactive objects remain.

    Also Creature Register does not seem to properly count and use pooling.


    I remember on previous version pooling was working fine.
    Is this some bug , or did i miss something new ?
     
    Tethys likes this.
  20. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Recycle Function On ICE Creature Register Not Working . So As a result New Instances Of AICreatures Are Created When Respawning After Culling instead Of Reusing The Old Disabled Creatures instances.
     
  21. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    484
    Thank you @icetec for the 1.4 update and the included tutorials. I am fooling around with ranged weapons now use the cover Teddy example. Run into a minor issue that I could use some advice on. I added a reload animation to the set used by the evil teddys. I set up a RELOAD behavior and in the FIRE behavior, added a link to it. It works great, but is there an easy way to have the reload animation triggered after the fire animation has gone off say, 4 times?

    I was thinking that maybe this can be done with the status or influences? No idea how I would accomplish it and could use a leg up. The manual doesn't cover anything related to ammo counts.

    Thanks!
    Mark
     
  22. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Hello PIT Just Check This Video . Whats The Problem Causing The Creature To Act Like That

    On Start The Creature Correctly Move Towards The Target But as Soon As It reaches the Slope The Problem Starts . How To Fix That
     
  23. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Also The Stopping Distance Is Broken For NavMeshAgent . Both The Target Stopping Distance And NavMesh Agent Stopping distance Are Same So The Creature Never Reaches The Target Location and Creature hangs At A Fixed Position Just before the Target Location . And Walk Animation Plays Infinitly Unless We Move Target Location Little towards The Creature To Make Him Reach The Target .
     
  24. icetec

    icetec

    Joined:
    Mar 11, 2015
    Posts:
    592
    Hi zenGarden, while using the culling option of a creature you should also activate the 'Spawn Conditions' of the creature register, so creatures will not spawned outside of a given culling area. That's also the reason for the disabled creatures - they were spawned outside of the specified culling area and therefore deactivated directly. And since up to 100 simultaneous creatures are allowed to exist (according to your settings), the pool management creates new ones. Using the 'Spawn Conditions' of the register should fix this issue ...
     
    zenGarden likes this.
  25. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Can You Elaborate How To Fix . What The values Should Be
     
  26. icetec

    icetec

    Joined:
    Mar 11, 2015
    Posts:
    592
    Do not worry, there is e-mail support, but it can take a while because of many requests.
     
  27. icetec

    icetec

    Joined:
    Mar 11, 2015
    Posts:
    592
    Hi danteswap, I'll check it and if there is a bug I'll fix it directly and will provide an update here in the forum.
     
  28. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Ya Sure Thanks For The Support I appreciate that.
     
  29. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    @icetec - I may have found a bug. The effect for Dead doesn't work. Tried for last 2 days to get this to work - I'm settling on its bugged. Here is the screenshot, identical settings to Defend. I tried to set this up two days ago, got frustrated it wasn't working and gave up. Came back to it last night and today, confirmed its broken. When the Defend behavior fires the Effect works as planned and the particle spawns. When set up the same exact way on Dead behavior nothing happens - it just never spawns. Also, with inventory, there is a bug. If you do not set to DetachOnDie, the inventory item just doesn't spawn at all. Had to find a workaround as I was trying to keep an inventory item parented to the item on death so that it could grab a component. No good - just doesn't seem to work if that DOD isn't checked. Checking it the item spawns, no check, no item spawn in hierarchy. Apologies if I have something incorrect.

     
    Last edited: Nov 7, 2017
    jonfinlay likes this.
  30. froslie

    froslie

    Joined:
    Apr 20, 2015
    Posts:
    18
    [Edit_2]:
    I've gotten this to work much better with "AI Path Script" from A*. It appears to have been an issue with RichAI, which I can't seem to get to work correctly.

    [Edit_1]:
    It seems that I have Astar working, but the creatures don't follow the path directly. If I remove the grid, the creature follows the same path anyway, which indicates there is another navigation system operating. Can't figure out where/ why this is happening.

    The smooth modifier component is added in this example.







    I am requesting further clarification regarding proper A* [AStar] function

    The difficulty with A* is that the creature does not seem to be following the correct path. It seems like the A* is working, but the creature is just wandering according to to some other system. Could someone please explain the proper basic setup for a creature using A* with advanced animation?

    My approach: [1] add A* 'pathfinder' component to empty gameobject, setup grid. [2] add 'seeker' and 'ICE Pathfinding adapter' to creature (also, change navigation to custom). [3~] have been trying a character controller on creature per Pit's notes.


    Have been beating my head... thank you and I appreciate your time!
     
    Last edited: Nov 11, 2017
  31. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    @icetec - I also seem to be seeing issues with pooling. I already had my settings as you have suggested, culling on the creature, spawn conditions on the creature register, both the same. I have max objects set to 3 out of 3 for the creatures I am using(also tried 3 of 5 in case it needed extras for pooling). When hitting play I keep the hierarchy open so I can see what is spawning into the scene. When I kill the creature and they respawn I can see it respawn in front of me(spawn point is me) and keep spawning new instances and leaving the ones I have killed as inactive. I have also tried turning the Pool Coroutine option on and off and doesn't seem to fix it. I get up to 6-10 instances in the multiple tests I tried(start with the first 3, kill them and watch them respawn). Didn't bother trying to go past that. Here are my settings:
     
    Last edited: Nov 8, 2017
  32. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    How To Spawn Creatures At Fixed Spawn Points . Like 3 Creatures At 3 Pre-Defined Transform Positions.
     
  33. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    Thanks Pit.

    And should you secure that on your plugin by automatically force and set the Spawn Conditions if we check culling ?
    Because it makes no sense that the plugin let's you set up culling while forgetting the Spawn Conditions.
     
    Last edited: Nov 10, 2017
  34. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    484
    Create an empty game object at each location that you want to spawn at and make each one the HOME object for the creature that you want to spawn there. Set the random spawn range in the Creature Register to 0/0.
     
    icetec likes this.
  35. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Ya I Did That But I Want 3 Of Same Type Of Creatures To Spawn At Those Locations . I Mean Like We Have 3 Positions and One Pool Of Creature with Like 20 Creatures in It Now I want 20 Of Them To Randomly Spawn On those 3 Spawn Locations .I mean they if I got Not 20 But Only 3 the all Three Of them Should spawn on different locations (From Only those 3 locations)
     
  36. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    484
    OK, so I believe that random spawning can be done the same way. I'm doing this in my WIP, but I haven't verified its randomness. Give the spawn locations a tag (like BadGuySpawner) and then select that tag as the spawn location for the creature. Anything else requires coding.

    Anyone else?
     
  37. jonfinlay

    jonfinlay

    Joined:
    Aug 25, 2015
    Posts:
    535
    I noticed exactly the same thing, in fact I wrote it a few posts above yours on Saturday. Nothing seems to work the in Death behaviour except the death animation, and perhaps the audio though I've not checked it. The Events don't work neither do the Effects.
     
  38. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    This is concerning. Will do some tests of my own today.
     
    mattis89 likes this.
  39. icetec

    icetec

    Joined:
    Mar 11, 2015
    Posts:
    592
    Hi Danteswap, there was in fact a small bug with the body orientation for quadruped creatures, but here you can find an update to fix it ...

    icecreaturecontrol.com/files/ice_CreatureMoveUpdate_1_4_0_1.unitypackage

    In addition, I will publish a minor update in the store to fix the mentioned issues.

    Have a great day!

    Pit
     
    Ryuichi173, Tethys and jonfinlay like this.
  40. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Hey Pit Thanks For The Update , It indeed fixed the rotation Bug For Internal Motion Control ,But Now the Bug Comes When We Use NavMeshagent. I Have Double Checked It by manually Replacing The Ice_CreatureMove Script With previous one And Guess What The nav Mesh agent is fixed but we get that bug with internal . And when I replace That Script with The Current one you provided The Internal Motion Is Fixed But The Bug Comes When We useNavmesh Agent and rotation Of Creature On Slope Doesn't work . So Please Look It One more time . And I am Still Waiting For RFPS integration Tutorial You Promissed . thanks for The Effort
     
  41. Gamarray

    Gamarray

    Joined:
    Apr 21, 2017
    Posts:
    4

    Hi @icetec

    Can you tell me if the Dynamic Visual Sensor position is Working? I've attached an Screenshot of my problem.

    Hope you can help me.
     
  42. icetec

    icetec

    Joined:
    Mar 11, 2015
    Posts:
    592
    Hi Tethys, have fixed the issue with the pool management and the conditional spawning. The Spawn Conditions of the register are obsolete now. I've followed your suggestion, so the register is using now the Culling Options of the associated reference object directly. In addition, I've improved the culling option so that a culled object is no longer removed by default, but first disables its renderers and restricts its functionality, furthermore an optional period of time can be defined after which a culled object will be removed. So a creature stays near to its last known location and becomes visible again if the player turns around and / or goes back.

    Have to test it now with different scenarios and will provide you an update.

    Have a great day!

    Pit
     
    Tethys and Ryuichi173 like this.
  43. icetec

    icetec

    Joined:
    Mar 11, 2015
    Posts:
    592
    Hi Gamarray, for using the Dynamic Visual Sensor position you should select a child object which is near to the eyes of the creature. The best practice is to create an empty object as child object of the head, rename it and place it in the correct position. Please consider also the correct rotation (z-axis = forward). Also make sure that there are no colliders which could block the raycast beam. Btw. according to you attached image, it seems that you already use an object as origin but please check its correct position ...
     
  44. Gamarray

    Gamarray

    Joined:
    Apr 21, 2017
    Posts:
    4
    Hi @icetec , thanks for the quick response.

    It is an empty child object of the head (outside the colliders), and the Z axis is forward.

    Should I add another script (such as Ice Creature Body Part or something like that) to the object i'm using (named "FOV")?

    Thank you
     

    Attached Files:

  45. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Thanks man, that sounds perfect! I was just trying to sort how to handle placing a sentry at a players house, as when they leave we remove the terrain but the terrain stores all the placed items (which AI is not). This will solve that future problem. Thanks again!
     
  46. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    484
    I have my Companion AI working pretty good thanks to the "Cover" tutorial. That helped A LOT! Now, I wonder if anyone has an easy method for AI changing from a ranged weapon to a melee weapon when the bad guys get within striking range?
     
  47. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Greetings @icetec - Sorry to be a bother but I found another bug. This one is rather strange. I have my own health and UI system I tried to integrate but cannot get it working with ICE so decided to try your UI system for creatures that you so very nicely included with the package. I set it up on 1 of my mobs, made sure all the UI slots were filled, everything looks good. I even use the name feature, very nice.

    The bug happens at runtime. When my player spawns in and starts walking, the mobs that have the IceCreatureControlUI script on them run the same direction as my player, and turn as well when the player turns. I try to chase them down (player runs a little faster) and get real close, but they are all doing the same thing, running away from me and turning with my turning. Strange. Player prefab has the Player script on it and the IceCreatureLocation script on it (I used this to get around the issue with not being able to find something by TAG if it isn't in the scene on setup). If I remove the IceCreatureControlUI script from the AI agents the bug goes away. Lastly, and this is the worst part, when the creature dies from combat, and has the script enabled.... it locks up Unity and I cannot return to normal - have to do a task manager window and force a shut down of Unity. Not complaining so much as just making you aware and would like to confirm if anyone else has seen this.
     
  48. Mad_Mark

    Mad_Mark

    Joined:
    Oct 30, 2014
    Posts:
    484
    I cannot seem to get the player to climb the ladder. Even in the House demo scene, the player can get on at the top, but once down, cannot climb back up.
     
  49. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Did Apex Path integration ever get into ICE? As I recall, it was promised in the next major release and that should have been 1.4.
     
  50. danteswap

    danteswap

    Joined:
    Oct 27, 2013
    Posts:
    164
    Hey There I Need Urgent Help I Am Using RFPS With ICE And Cant Get The Damaging Working Correctly Can you please provide a working RFPS Integration Tutorial OR Just Give Some Insights On How To Setup Because Every Time I Add Ice_Player Script Onto the FPS Prefab Provided By Realistick FPS Prefab Everything Gets Messy And Player Starts to Float And Skid And The Damaging Doesn't Even Work I mean I Am Not Able To Set It Up Correctly