Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Tactical Shooter AI - Asset Store Pack

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

  1. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    Here Is second approach on tanks, and it worked!

    Few things are mentioned there to be aded to make it shine!
    squared55 Cheers man!
    Now is time to try some choppers!
     
  2. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
  3. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Looks awesome! I think you can stop that weird half-turning (or hull jitter, as you put it) by increasing the AnimationScript's minAngleToRotateBase value to as high as it will go.

    Also, if you don't want the rifle agents to shoot at the tank, you could put the tank on a different team, and only make other tanks or infantry with explosives target that team.

    With regards to making the bullets not damage the tank, I would just make it so the damage is so low compared to the tank's health, you can't notice it's doing any damage at all. Make the tank health 1000000000 or something ridiculous like that, and it would take literally years for the rifles to kill the tank. You can increase the damage done by the weapons that should kill the tank to compensate.
     
  4. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    Helicopter using navmesh brings some difficulties so far.
    Is there any way for agent to not depend on navmesh?
     
  5. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    There'd be quite a bit of coding required for an alternate steering system. But yeah, the navmesh won't really work with flying vehicles.
     
  6. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    squared55
    Here are helicopters first video with areal stuff and some humble thoughts and questions)
     
  7. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    Have progress with helicopters!
    Will post bit later.
    squared55 have you seen video above?
     
  8. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    I'm actually pretty impressed with what you've managed to do with the included scripts. I definitely didn't expect them to be used in this way.

    You can use a convex mesh collider, but you would have to manually attach and assign the hitbox script. I don't believe you need to reference it from any of the main body scripts, but you do need to provide the hitbox script with the object holding the health script.

    For your error, I think you'll have to uncheck the option on the gunscript that says whether or not the projectile is a grenade- I forget the exact name, and I'm not in a position to check at the moment.

    For the falling through the floor, I would move the origin of the chopper back inside the main body, and instead offset it by placing it inside an empty gameobject and then moving it from there.

    But yeah, it would definitely be best to make a dedicated helicopter AI system.
     
  9. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    I did small cube with transform offset to be the parent of helicopter body with centered transform in Blender and assigned helicopter body as bone to rotate in agent setup wizard. Creating agent that way allowed helicopter body to rotate towards its targets and be stable having small parent cube assigned as root object in wizard.
    Attaching rigid bodyies to agent and cube allowed helicopter body to fall down after agent being dead!
    Making one field for bone to rotate x, and another field for differnt bone to rotate y in tank wizard would let turret turn just in y axis and gun to rotate in x axis, perfect for tanks and alike! So user could clamp values for separate axis in inspector after agent creation.
    I'm not in my home town for few next days so will miss it a lot) and will give it all my thoughts!
     
  10. sonnolo

    sonnolo

    Joined:
    Feb 22, 2015
    Posts:
    26
    Are possible spawn multiple bots at same time(8 for example)?
     
  11. sonnolo

    sonnolo

    Joined:
    Feb 22, 2015
    Posts:
    26
    Doesnt work for me,when i kill ai bot just one enemy respawn,if i set 3 bots same video just one spawn
     
  12. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    I suppose you could attach multiple copies of the script to the agent. It would probably be best to write a script specifically for your game though, in order to get the exact functionality you want.

    Where are you attaching the scripts to? Are you destroying the spawn point after using it, say by making it an agent?
     
  13. sonnolo

    sonnolo

    Joined:
    Feb 22, 2015
    Posts:
    26
    No,i ave spawner script attach to ai agent and spawnpoint script to empty object with Spawn tag but unity just spawn one bot,if i set 4 or 5 for example unity just spawn one and ignore this
     
  14. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Well, it seems to work fine for me. No special set up, just one script on the agent, the other on the spawner. Assigned prefabs to the spawn point script, and that's it. Check to make sure you aren't destroying the spawn point.
     
  15. Shadex

    Shadex

    Joined:
    Dec 18, 2013
    Posts:
    89
    Is there a tutorial on how to setup an AI that uses the Meele attacks, such as someone using a sword? Perhaps a zombie tutorial? Could anyone point me in the right direction? Every time i try to set up an enemy the animation's do not work, and it gets stuck in the blend tree where the walk animations are. The default soldiers work fine, so i know its something with my setup.
     
  16. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Have you tried just duplicating the default animation controller and then replacing the placeholder melee animation with your new animation? Then you'd apply that controller to the agent.
     
  17. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    Would it be possible to make few changes in next update:
    two separate fields in agent wizard for bone to rotate x, and for bone to rotate y.(for tank turret)
    Secondary fire mode to have same controls as primary fire mode(fire rate,etc.)
    Ability to assign few bullet spawnpoints for either fire mode.
    Damaged effect for agents(to apply smoke particles,sound,and damaged mech to dying agent)
    Thanks
     
  18. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    It would be great to have approach distance values for agent to stay at sertain min and max range from its target(so they couldn't come close to theyr target.
    For now i can't prevent helicopters from stayng motionless right above tanks they're attaking.
    Tried to tweak Skirmish behaviour values, but it didn't help.
     
    RangePlusOne likes this.
  19. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    I make no promises about *next* update specifically, but in response to your specific requests.

    This would likely require a radical change in the way aiming is done, and the result would probably be pretty useless on humanoid agents. So it probably won't appear until if I make dedicated tank AI.

    I'll see what I can do!

    This should be pretty easy.

    This is a good idea.

    I've been wanting to add this for quite a while, actually. Haven't yet found a good way to do it though.

    Keep cranking up those distance values!
     
    Last edited: Apr 27, 2016
  20. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    Is that a yes on multiple bullet spawnpoints?

    I was talking about approach distance to target that is in agent's clear field of view and agent is currently attacking.

    Damaged and dead states with fields for particles, sounds, and replacement meshes(wrecks) would be great for dead technical units.

    Heavy mg on tank turret and helicopter mg are good candidates for duplicated sight and fire functionality.

    Would it be to much to hope for tank ai beta?
     
  21. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    I'm not willing to 100% commit on anything, but I'd say this is fairly likely given the current situation.

    Right, but there's a lot of things you need to take into account. What if the target moves closer? What if the agent needs to move past the target? What if there's a wall in the way? What if there's a hole in the ground between the two? What if there's a bridge separating the two some distance apart? What if one is on a floor higher than the other? etc.

    The simple "stay in range x with line of sight" I think you're talking about seems covered by the Skirmish behavior already. You may be getting some weird behavior because your agent is so far off the ground, though. Are you sure you set the agent to use the skirmish behavior instead of the Tactical or Berserker behaviour?

    At this point, I'm not even sure if I'm going to add vehicle AI to the package yet. It would definitely be expanding the scope beyond what was originally intended, and I think I might want to focus more on the infantry AI.
     
  22. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    Well you could see for yourself how close you are to have fully feautured combat sistem!
    It's awasome as it is wright now to be honest)
    I'm intended to go to Moscow Devgamm conference in 11-13 may with this project!
    Hope to grab few publisher deals there.
    Will gladly use any extra feauture to spice the dish though)
    But anyway thanks for everything you made that turned to be so versatile and robust sistem!!!
    Tank you sir)
    Cheers!
     
    squared55 likes this.
  23. googlebac

    googlebac

    Joined:
    Feb 1, 2015
    Posts:
    56
    Hi Squared, in reguards to your sound script. Can I place that on my UFPS character and have them invesigate sound I make?

    EDIT I actually mean this one:


    Also is there a way to make them drop their gun when they die?
     
  24. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    The sound script I posted will only work one time when the object is spawned, so what you'll want to do is call this method

    Code (CSharp):
    1.  ParagonAI.ControllerScript.currentController.CreateSound(soundPosition, soundRadius, arrayOfTeamsThatShouldHear);
    whenever you want a sound to be played. Obviously, you'll want to replace the variables with your own. You could make a script that uses the OnAIDeath() method and attach it to the agent. You would then make the script

    -De-parent the gun from the agent's hand
    -Enable a rigidbody
    -Enable a collider
    -Do anything else you need to do, like enable a script that lets the player pick it up, for example.
     
  25. rbm123

    rbm123

    Joined:
    May 24, 2015
    Posts:
    129
    how can i make agents follow me and engage with enemy?
     
  26. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Set the agent's KeyTransform to be your player, and they should generally orient their behaviors to be around you.
     
  27. googlebac

    googlebac

    Joined:
    Feb 1, 2015
    Posts:
    56
    Cool, thanks for that I'll get to work.
     
  28. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    Is there a ways to optimize base script
    i tried to comment out some of content of this function, as this method gives me 100 to 120 in editor and ten times less
    on my Galaxy S 3.
    Code (CSharp):
    1.         IEnumerator AICycle()
    2.         {
    3.             //Will stop if the script is disabled at any point.
    4.             while (this.enabled)
    5.             {
    6.                 if (currentBehaviour != null)
    7.                 {
    8.                     currentBehaviour.AICycle();
    9.                 }
    10.  
    11.                 //Check to see if we should dodge.
    12.                 //Dodges are automatically triggered after spending time in their target's line of sight
    13.                /*if (!isDodging)
    14.                 {
    15.                   if ((myTransform && targetTransform && canMelee && !isMeleeing && Vector3.SqrMagnitude(myTransform.position - targetTransform.position) < meleeRange))
    16.                     {
    17.                         isSprinting = false;
    18.                         animationScript.StopSprinting();
    19.                         SetProperSpeed();
    20.                         headLookScript.Activate();
    21.                         //StartCoroutine(AttackInMelee());
    22.                     }
    23.                     else
    24.                     {
    25.                         if (!isMeleeing && Vector3.SqrMagnitude(myTransform.position - currentBehaviour.targetVector) > distFromTargetToSprint && canSprint && engaging)
    26.                         {
    27.                            animationScript.StartSprinting();
    28.                            SetSprintSpeed();
    29.                            headLookScript.Deactivate();
    30.                         }
    31.                     }
    32.                 }*/
    33.                 MoveAI();
    34.  
    35.                 /*if ((!targetTransform && !engaging))
    36.                 {
    37.                     isSprinting = false;
    38.                     animationScript.StopSprinting();
    39.                 }*/
    40.                 /*else*/ if (Vector3.SqrMagnitude(myTransform.position - currentBehaviour.targetVector) < distFromTargetToSprint && engaging && !isDodging)
    41.                 {
    42.                     animationScript.StopSprinting();
    43.                     SetProperSpeed();
    44.                     headLookScript.Activate();
    45.                 }
    46.                 yield return new WaitForSeconds(cycleTime);
    47.             }
    48.         }
    Could you help me with your spawner?
    In tutorial on spawner there is one Agent respawning from one spawn point. But i can`t make it so two or few spawnpoints on each team would do the job.
    Thanks.
     
  29. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    This AICycle corutine is eating 82 % of my cpu :(
     
  30. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    I may look into adding a "performance mode" in a later update.

    You will probably want to give each team's spawnpoint a different tag and modify the script to accept a string variable rather than the hardcoded value there is now. If you take a look back through the thread, I did post a modified script that allows you to have multiple spawn points that you could work off of.
     
  31. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    Thanks man.
    I tried it two times but i did something wrong each time or something i`m missing.
    I`d be enormously greatfull to you if you could make short video about your new spawner`s setup for opposing teams.
    Appreciate your help brother!
     
  32. PixelPaw

    PixelPaw

    Joined:
    Feb 18, 2013
    Posts:
    91
    Hi like the asset so far, was wondering I don't see the layer's name on the environment ?
     
  33. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    The only change from before is that you need to assign spawn transforms in the inspector. Only tag the object with the script with your spawn tag, do not tag the spawn point transform markers. And make sure you're using the right script, obviously.

    As for using both teams, the easiest, but less efficient way would be for you to just duplicate the script you put on the agent and just open the code and modify the tag for the other team. However, declaring a string variable and then replacing the tag name with this variable would be the better way of doing this. Add your spawn points and modify the agents on the other team accordingly.


    Hi! That's caused by Unity not importing my layer set-up. You could add the layer yourself, or just start dropping agents in your own map. Just make sure you modify the layermasks on the bullets/cover nodes/controllers appropriately.
     
    Last edited: May 4, 2016
  34. ParadoxSolutions

    ParadoxSolutions

    Joined:
    Jul 27, 2015
    Posts:
    322
    @squared55 Hello, it has been a while since I've been here but I had to work on some other stuff but as I recall where I left off when using your asset I was trying to use the A* Pathfinding project's navigation instead of navmeshes. I remember you saying that you added a script similar to the custom behavior script for alternate pathfinding methods, if you could help walk me through on what I need to do for that it would be great, it has been to long for me to remember exactly what I had to do.

    It's good to see Redhawk on here, I'll have to read through older posts to see what you guys have been up to.
    I just submitted an asset I made in my spare time check it out: here I have a script in it for integration with UFPS but I may be able to tweak it and make one for the AI Agents (allows burn damage between assets).
     
  35. RangePlusOne

    RangePlusOne

    Joined:
    Dec 6, 2014
    Posts:
    123

    Hi guys, anyone have any idea why the AI are able to see me right when the map starts? I've layered it as 'Level Parts' ... they still go guns blazing always seeing the enemy and player.


    UPDATE
    Upon testing the demo scene I noticed that they layer is left blank?? When I changed them to default (because there is no blank option they act just like in forest picture above?) how do I select the blank option??
     
    Last edited: May 8, 2016
  36. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    This process should work:

    1: Extend the NavmeshInterface class.

    2: Override all the methods with A* compatible ones.

    3: Drag your new class into the Navmesh Interface field on the BaseScript.

    That should be all there is to it!


    I think you need to modify the layermask of your scene's AI Controller. Also, make sure you are using the most recent version of the package.

    The blank option is there because you don't have the LevelParts layer I had in my project in your project. Try and eliminate all references to it.
     
  37. RangePlusOne

    RangePlusOne

    Joined:
    Dec 6, 2014
    Posts:
    123
    Bingo! Thanks buddy!

    Is there a way to disable the NPCs ragdoll once they are dead? I read this in the docs, but unsure which to edit or how to apply the change so after say 1 second they disable?
    "Colliders to Enable: An array containing the colliders that should be enabled on this agent’s death. Good for gun models and other objects that shouldn’t be hit by bullets but should use physics upon death. "
     
  38. sashahush

    sashahush

    Joined:
    Sep 5, 2012
    Posts:
    75
    Can I use room motion to displace AI characters?
    Thanks!
     
  39. sashahush

    sashahush

    Joined:
    Sep 5, 2012
    Posts:
    75
    Hi there, is there a path finding script? Lets say i don't want to use Navmesh.
    Thanks!
     
  40. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    I can't say I've tried it.

    There isn't one included out of the box, however, you should be able to modify the NavmeshInterface class to work with another pathfinding system such.
     
  41. RangePlusOne

    RangePlusOne

    Joined:
    Dec 6, 2014
    Posts:
    123
    I think I;ve asked this question before but I can't find the answer... but the AI doesn't respond to the gunshots heard in the distance or when bullets fly near them? Any ideas why this could happen?
     
  42. ImAldu

    ImAldu

    Joined:
    Mar 6, 2015
    Posts:
    64
    This is awesome, guy. I really do like this. Do you have future plans that I can read? Perhaps a blog?
     
  43. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    238
    Tried it the way you said. No spawn(
    Also in last update noticed major lag. Gun script's Fire method eats up to 45 percent of cpu.
     
  44. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    You need to use the CreateSound method, the line in question being a bit up the page here.

    EDIT: Got to desktop, here's the line :)

    Code (CSharp):
    1.      ParagonAI.ControllerScript.currentController.CreateSound(soundPosition, soundRadius, arrayOfTeamsThatShouldHear);
    2.  
    I appreciate the support. :)

    I made a post a page or two back of stuff I want to do, but I'm wary of giving constant updates just because everything changes so much so often.

    I imagine it's because you've added a weapon with a high rate of fire, or done something to the bullets. Try turning it down. I don't think I've touched that method since the first release, though.
     
    Last edited: May 12, 2016
  45. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Hi squared55, I have read through the manual linked at the start of this thread. This looks like a fantastic asset and I have a few questions about it if you don't mind.

    1) Is it possible to create a guarding behavior for AI? What I mean by this is that the AI by default will stay at a specific guarding location (not moving), and if it detects the player it will start chasing it, trying to kill it etc. If it loses the player during the chase, it will then return to its guarding location. This would be used for guarding doors, loot etc.

    2) How does the AI detection work and what can be adjusted? For example do the AI use line of sight, listen to sounds etc? Also, if the player is detected is there a way to set how long the AI will continue the chase before giving up, and what the AI will do if it has lost the player eg. wander, stay in place, return to some location etc?

    3) Can the AI switch between multiple weapons? I noticed there was a tutorial on this for the previous version of the asset, but I am curious if the AI can for example use a rifle when the enemy is far away and switch to a knife when they are close. Or for example use their primary gun, and when it has run out of ammo switch to their side arm.

    I look forward to your reply.

    Hamesh
     
  46. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    1) Yes, this is possible.

    2) The AI will engage in combat when they spot an enemy. However, you can create "sounds" that will draw the agent to investigate. The agent will give up when the target moves a certain distance from where they were last spotted. You can also adjust the frequency of target checks. When the agent loses a target they execute their idle behavior (which could be wandering, staying in place, or returning to some location). You can also create custom behaviors if you need something beyond what is included.

    3) Unfortunately, this is not in TSAI at the moment. However, melee animations are supported, and you could make the agent pull out a knife for a melee attack.
     
    Last edited: May 23, 2016
  47. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Thank you for clearing that up. For the pathfinding, is it possible for AI agents to navigate through multiple level type structures, such as buildings with several storeys where the floors are overlapping on top of each other? I have used some AI assets in the past, and they were not able to create navmeshes that overlapped.
     
  48. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    The asset only utilized standard Unity NavMesh. So, it would depend on if it is a capability or limitation of Unity, not the asset per se.
     
  49. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    It uses the defaut Unity navmesh, so yes. For proof, you can check out the UFPS web demo which has two levels. :)
     
    Hamesh81 likes this.
  50. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Ok great. Oddly enough I have never actually used Unity's navmesh system before, since when it was released there were a number of limitations. It sounds like those limitations are now gone so I will have a look at it. Thanks