Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Tactical Shooter AI - Asset Store Pack

Discussion in 'Works In Progress' started by squared55, Mar 2, 2015.

  1. Prefab

    Prefab

    Joined:
    May 14, 2013
    Posts:
    42
    Hi @squared55 , looking to purchase this asset but just wondering whether there are any plans for ladder support and also network multiplayer at any stage?
     
  2. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Try attaching the SoundMaker script to the bullet impact effect prefab, and configuring it as appropriate.

    I currently do not have any plans to add support for those, no.
     
  3. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    215
    What are the plans or roadmap for this asset ? any new features coming or development is stopped ?
     
  4. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    I don't have a concrete roadmap for the asset. The next feature I want to implement is having agents lead their targets, but I've been pretty busy with unrelated things recently so I don't know when I'll have a chance to implement it.
     
    Last edited: Apr 9, 2018
    qpJaKeWaGGqp likes this.
  5. GWStudio

    GWStudio

    Joined:
    Sep 27, 2016
    Posts:
    62
    i did it but the agent get back to patroll before arive to sound location.. how to make it investigates or wonder arround the sound position then if he didn't find the player get back to patrolling .. one more issues how to make the grenade damage my RFPS player ..
    Thanks for answering. .
     
  6. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Default behavior of the investigate sound function is to do just that- go close to the location of the sound and then return to the idle behaviour. I can look into making you a version of the investigate sound function that has the agent wait around a bit after reaching the sound source. (However, as stated above, I'm pretty busy at the moment, so this might take me a while to get around to.)


    As for making AI grenades damage the RFPS player- in short, open the TSAI explosion script and uncomment the RFPS lines in the middle. Then set the layermask appropriately so it doesn't interpret the RFPS player itself as a wall and do no damage. More detail can be found in the RFPS integration instructions included with the package.
     
  7. khaven

    khaven

    Joined:
    May 24, 2017
    Posts:
    2
    Hi squared55, is there any way i can use object pooling with ai gameObeject? I'm trying to use this on mobile platform.
     
  8. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    People other than me have done it, but it did require some code modification. IIRC, someone actually made a video demonstrating how to integrate TSAI with an asset called Pool Boss, but on taking a brief look, I can't seem to find the video again.
     
  9. Virtuactions

    Virtuactions

    Joined:
    Jun 5, 2017
    Posts:
    10
    Hi, bots on my map are pretty stupid and i don't understand why.
    http://take.ms/WIaZt
    I start 10x10 battle, there is still plenty of blue soldiers, but all red soldiers stand near one of them and do nothig. This blue soldier is shooting randomly. And this is not the only strange thing. Often bots don't see each other in 1 meter distance. They can stand on one place for 2-3 minutes before start moving, or don't move at all. They move in group without reacting to enemy bots. Bots in one team can intentionaly shoot each other. And bots like to shoot to nowhere.
    And on demo map everything works ok. What can it be?
    I am using same bot prefab like on demo map, only change their team parameters at runtime on awake (team, allied teams, enemy teams).
     
  10. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Have you configured the AI Controller to match the demo scene? You should also use the "SetNewTeam(int newTeam)" method to change teams if you are not already.
     
  11. GWStudio

    GWStudio

    Joined:
    Sep 27, 2016
    Posts:
    62
    I hope u make the version of the investigate sound function that make the ai to investigate around the sound location??!!
     
  12. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Sorry for the late response. Like I said, I was extremely busy.

    Anyways, here is a version of the Investigate Sound behavior that will cause the agent to wait for a certain amount of seconds before returning to their regular idle behavior.

    Replace the InvestigateSound class in the CustomAIBehaviour with this one.

    Code (CSharp):
    1. namespace TacticalAI
    2. {
    3.     public class InvestigateSound : TacticalAI.CustomAIBehaviour
    4.     {
    5.  
    6.         float radiusToCallOffSearch;
    7.         //Change this to change the amount of time the AI waits!
    8.         float timeUntilReturnToIdle = 10.0f;
    9.  
    10.         public virtual void Inititae()
    11.         {
    12.             base.Initiate();
    13.             radiusToCallOffSearch = baseScript.radiusToCallOffSearch;
    14.         }
    15.  
    16.         public override void AICycle()
    17.         {
    18.             //End the behaviour if we get close enough to the source, or we engage a target.
    19.             if(navI.GetRemainingDistance() < radiusToCallOffSearch)
    20.             {
    21.                 timeUntilReturnToIdle -= Time.deltaTime;
    22.             }
    23.  
    24.             if (timeUntilReturnToIdle <= 0 || baseScript.IsEnaging())
    25.             {
    26.                 KillBehaviour();
    27.             }
    28.             else
    29.             {
    30.                 targetVector = baseScript.lastHeardNoisePos;
    31.             }
    32.         }
    33.  
    34.         public override void OnEndBehaviour()
    35.         {
    36.             Destroy(this);
    37.         }
    38.     }
    39. }
    Let me know if it works.
     
    julianr likes this.
  13. Virtuactions

    Virtuactions

    Joined:
    Jun 5, 2017
    Posts:
    10
    How can I get bot who is owner of bullet, that hit me? Is there any built in method or i need to modify plugin code to achieve that?
     
  14. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Unfortunately, there is no built-in way to tell which bullet was fired by what agent. You may want to attack a new script to the bullet prefab instead of modifying the TSAI code, though.
     
  15. Virtuactions

    Virtuactions

    Joined:
    Jun 5, 2017
    Posts:
    10
    So I need to create a bullet prefab for every bot and assign this prefab to gunscript at runtime?
     
  16. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    That's one way to do it. But, upon thinking about it more, the best way would require only a bit of modification to the code.

    First, you'd make a script which holds the ID of the agent which fired the bullet and transfers the data to the target (or you could integrate it into the existing bullet script, if you'd find that easier).

    Then in the GunScript you would access this new script/code when the bullet is instantiated and provide the information that way. You can look to how I set the target of homing rounds for an example.
     
  17. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    367
    Great job on the plugin!

    What is the best way to give a new destination to the ai agent. For example, a new base or flag to defend during the game? I tried setting the key transform of the BaseScript to the new target transform and setting the idle behaviour to "moveToTransform" but I think this only seems to work when the agent is first instantiated not during gameplay.
     
  18. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    "Berserker" is the combat behavior which moves the enemy to a specific point. By default, this point is the target, hence the name, but you can override the destination via the key transform.
     
  19. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    367
    Ok great thank you.

    Will using berserker behavior let the agents still engage enemies along their path? one thing I noticed with the move to transform behaviour was that they would often run right past enemies in a blind rush to the destination, which looks a bit funny that they ignore an enemy a few feet away.
     
  20. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    367
    As a general suggestion for coding that might make the plugin a bit more extensible, would be to provide more virtual functions that can be overridden to allow for easier customization without having to edit your original code.

    Also things like the spawner have a reliance on a hardcoded sendMessage that will only work with the spawnerscript class as it is written. This is when a new unit is spawned and then it looks like the spawner registers itself with the new unit so that when the unit is killed the spawner will be notified, but as it takes the spawner itself as a parameter, it will only ever work with that specific spawner class. Would be cool if this was a bit more generic and instead of passing in the spawner as the parameter, we just passed in the gameobject so that the agent could send out the killed message to any script on the spawner object rather than only this one class.

    Anyways, just some general thoughts, but overall it's fantastic!
     
  21. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    367
    I tried the berserker style but they pretty much just run at the set destination without stopping for cover as much. I prefer the feel of the Tactical behaviour but is there a way to just give them a general point to move towards and make sure they do so carefully so they stop at cover, don't just run into enemy fire, etc..?
     
  22. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    You might want to try using the Advance Towards Target cover finding method along with Tactical. This will make them choose cover nodes that are progressively closer to the Key Transform.
     
  23. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,061
    Trying to get this working with Invectors TPC. So far so good, however when I apply the Target script on the Player, the AI do not see me, yet when I apply this script to the camera they do, but shooting at the camera which is behind the player. Any ideas?
     
  24. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Sounds like a layermask issue is causing the agent to view the player as a wall they can't see through. Try excluding the player's layer from the AI Controller's layermask.
     
    julianr likes this.
  25. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,061
    Thanks. I'll give it a go and let you know if it works.
     
  26. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    367
    Thanks. I tried changing the cover seek method to Advance towards target, but doesn't seem to change anything. They still don't move towards the key transform. Maybe you can give me some instructions based on this desired behaviour:

    1. I set a transform or position of an capture point for the agent i want them to proceed to
    2. They move towards that point, using cover if they are in combat, otherwise just walk towards it if not in combat
    3. Once the point is captured, I give them another point to move towards (repeat step 2)

    Any thoughts on how to accomplish that?
     
  27. Tomza

    Tomza

    Joined:
    Aug 27, 2013
    Posts:
    577
    Hi,
    I'm looking for a good AI solution. Is it possible to create AI bots as enemies for my player?
     
  28. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Are using manually placed cover nodes?

    You can use TSAI to make enemy NPCs, however, depending on what movement/other mechanics you player has, the TSAI agents may not be able to do everything your player can.
     
  29. Tomza

    Tomza

    Joined:
    Aug 27, 2013
    Posts:
    577
    Thank you.
     
  30. capitalJmedia

    capitalJmedia

    Joined:
    Feb 10, 2011
    Posts:
    367
    Yes, I put short and tall cover node prefabs into the scene along the path the agents take to get to a control point. I put the nodes as children of other objects (props, cars, etc..), not sure if that matters or whether the cover nodes need to be in the root of the scene.
     
  31. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    There's an error in the CoverFinderScript. Line 123 should read

    Code (CSharp):
    1. return FindAdvancingCover(targetTransformPos, transformToDefend);
     
  32. Kiwi2112

    Kiwi2112

    Joined:
    Jun 30, 2017
    Posts:
    7
    How do you get the AI to hear gunshots, they only detect me through vision (iv'e played around with the shout options.)

    Im also using UFPS.
     
  33. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    There should be a script included with the package that makes a "sound" the AI can hear when the prefab on which the script is placed is instantiated. So, putting it on your bullet prefabs should do the trick.
     
  34. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    17
    Hi,

    How would I go about disabling an agent's ability from engaging with other (enemy) agents until the player tells them to?

    In the game I am working on the player can command agents to follow and assist them and I would like to stop agents from engaging with enemies until the player commands them to.

    Thank you.
     
  35. Kiwi2112

    Kiwi2112

    Joined:
    Jun 30, 2017
    Posts:
    7
    Quick question, can this work with invector? I can hurt enemies but they just stand there, I have the teams all properly set in the target script.
     
  36. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Try setting the priority (on their TargetScript) for the enemies that you do not want the agents to engage to a value less than 0. Then when you want the agents to attack them, restore their priority to a value greater than 0.

    You could also change the priorities of the agents to different amounts based on player commands in order to get your friendly agents to focus fire (or do the opposite- give friendly agents a higer priority than the player to make distractions more effective).

    I don't offer official Invector support, but if you have the damage systems working together, that's 99% of the challenge.

    Have you made sure that the player's physics layer is not included in the AI Controller's layermask? If the player's target script object is hidden behind the player's collider, the agents might not be able to see it.
     
    Last edited: Jul 11, 2018
  37. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    207
    hi. I have two identical agents with same settings but one of them shoots at the other the same moment he sees him, which is good. Other one is practically identical to the first one but he does not shoot right away but startwalking to first agent and shoots only when he is at nearmele distance.
    What could that be?
    Help please!!!
     
  38. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Probably some discrepancy between the settings of the two agents. Do you have sprinting enabled on the agent that is not working? Are they both using the same combat behavior?
     
    Last edited: Jul 14, 2018
  39. PicturesInDark

    PicturesInDark

    Joined:
    Jun 13, 2013
    Posts:
    73
  40. ricogs400

    ricogs400

    Joined:
    Aug 4, 2017
    Posts:
    13
    This might be way late, but lookup Core Game Kit, it uses pooling and spawners and has tutorials on setting it up with TactAI.
     
  41. ricogs400

    ricogs400

    Joined:
    Aug 4, 2017
    Posts:
    13
    squared55,
    Are these variables 'timeBeforeTargetExpiration' or 'willEverLoseAwareness' in TargetScript still used? The one is a public var to be set, but it looks like the code that would use them is commented out. I'm setting up difficulty levels and I'd like to use them as some of my variables. Are they not used in the latest release?
    Thanks, and by the way this is a great AI system.

    public int timeBeforeTargetExpiration = 15;

    Here's the commented out sections where they appear in TargetScript:

    //Old target loss method
    /*IEnumerator CountDownToTargetExperation()
    ...
    yield return new WaitForSeconds(timeBeforeTargetExpiration);
    }
    }*/

    //public bool willEverLoseAwareness = false;
     
  42. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Yes, I changed the way target loss works a while back.
     
  43. ricogs400

    ricogs400

    Joined:
    Aug 4, 2017
    Posts:
    13
    OK, thanks. Do either of these parts of the TargetScript below make AI aware of enemies they haven't seen yet?
    In my game, I only want AI to engage if they have spotted an enemy, have been notified by a shout from another AI or a sound.
    If this does do make them aware of unseen enemies and if these parts are only to keep the action going in a deathmatch type scenario, can they be removed?

    *************************************
    //Settle for targets we can't see, if we have to.
    else if (!foundTargetWithLoS)
    {
    enemyScoreCheckingNow = Vector3.SqrMagnitude(enemyTransformCheckingNow.position - targetObjectTransform.position);
    if (enemyScoreCheckingNow < currentEnemyScore || currentEnemyScore < 0 || !foundTargetWithLoS)
    {
    currentEnemyTarget = listOfCurrentlyNoticedTargets;
    currentEnemyScore = enemyScoreCheckingNow;
    }
    *************************************
    //If all of the above fails, pick a random target- even if it's one we haven't seen
    if (currentEnemyTarget == null && enemyTargets.Length > 0)
    {
    currentEnemyTarget = enemyTargets[Random.Range(0, enemyTargets.Length - 1)];
    }
    *************************************
     
  44. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    That is so that idle behaviours like Search work as intended. If you use something like Patrol, then it can be safely ignored, as those behaviors are not tied to the currently selected target.
     
  45. ricogs400

    ricogs400

    Joined:
    Aug 4, 2017
    Posts:
    13
    Great, that should help with my tweaking the other values on the behaviors. I use Wander, Patrol and Search, so I will leave it as is because it seems to be performing well, I just wanted to make sure there wasn't something happening that might make all the AI types look like they know where the player is without having seen them.
    Thanks.
     
  46. Meena_Fari

    Meena_Fari

    Joined:
    Mar 27, 2016
    Posts:
    12
    Hi, @squared55 very first very great pack, love it,
    I want to know, how can I set distance, keeping enemy his distance from player, and fire from some distance.
    and must take cover after some time.
     
  47. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    The variables defining the desired combat/cover range and the minimum desired distance to the player when out of cover can be found in the Base Script and Cover Script.

    Choose "Tactical" for the agents combat behaviour if you want them to take cover.
     
  48. Meena_Fari

    Meena_Fari

    Joined:
    Mar 27, 2016
    Posts:
    12
    Thanks for reply, but I am having issue, When I select mode to Tactical, agent simply goes to player, and shooting, not taking any cover, just firing and going to player position. but I want agent, firing some time towards player then should take cover at different position,then fire and after fire change position, and fire, again and again , until unless it dies. Even my cover positions are well set, in scene, according to your demo scene, I am uploading image of my base script and cover, kindly guide me. for my scenario (bold text). tac.JPG
     
    musolo likes this.
  49. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,803
    Have you set the layer masks on the AI Controller/Cover nodes to include the objects that make up your level? If you haven't the AI will be unable to find valid cover as it doesn't know which objects are solid.

    Similarly, make sure that your player's physics layer is NOT included.
     
    Last edited: Aug 8, 2018
  50. Meena_Fari

    Meena_Fari

    Joined:
    Mar 27, 2016
    Posts:
    12
    still, issue remain as you can see in image,, enemies are at player position, and don't know why, .. have you any tutorial about setting tactical and cover behavior 369.JPG
     
    Last edited: Aug 9, 2018