Search Unity

Tactical Shooter AI - Asset Store Pack

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

  1. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    There was a rather long discussion on the subject in earlier this thread, but I can't seem to find the posts again. That's all I've got on the subject of integrating A*.
     
  2. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    Hello all. I created a video showing Core Game Kit spawning Tactical Shooter AI. I have a link to my website where I have all the changes needed for the Tactical Shooter AI to work with spawning.


     
    squared55 and hopeful like this.
  3. catjack

    catjack

    Joined:
    Sep 30, 2014
    Posts:
    12
    hello Squarred55, hello guys!
    Can you help me out please, I lost a few hours trying to find the bug: the AI shoot me by wall, over and over again.
    -the tags are ok- layers set to LevelParts
    -nav mesh ok
    -Controller object is in the scene
    -AI are set to Tactical -wander
    -I have a huge wall between me and ai and still same sh*t.

    When I create an empty scene everything seems to be ok.
    What I am doing wrong here?

    thank you so much,
    Jack
     
  4. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Hello!

    I'd love to help, but unfortunately I'm not sure what you mean when you say "the AI shoot me by wall". Could you please expand on this?

    Are the bullets going through the wall? If so, it's an issue with the colliders on the wall (make sure you have a collider on the wall), or the layer of the wall, or the layermask variable of the bullet's bullet script (set to everything for testing purposes).

    Are the AI's shooting at you when there is a wall that blocks their sight? If so, it's an issue with the layers of the wall, the layermasks AI controller, or the gun script.

    Or is it a different problem? :)
     
    Last edited: Dec 6, 2016
  5. catjack

    catjack

    Joined:
    Sep 30, 2014
    Posts:
    12
    yes, the AI see me through walls/obstacles.
    Please see the video.I see that some people facing the same problem.
    This will help.
    thank you again!
     
  6. papathor

    papathor

    Joined:
    Oct 8, 2012
    Posts:
    41
    Squared,

    What's the best way to use TSAI's aiming/shooting/dying features without the actual pathfinding/moving? I'd like to use TSAI for everything except navigation because my map is procedurally generated.

    Is just commenting out code the best way to do this? If so, what should I comment out?

    Thanks for the help!
     
  7. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    OK, I see a few potential culprits here:

    1: The gunScript's "dist allowed in front of target for cover" value is too high. Try decreasing it.

    2: The baseScript's "minimum distance to target when out of cover" value is too high. Try decreasing it.

    3 (most likely): There is no continuous navmesh to get from the agents to the player. You will have to modify the navmesh settings until you can trace the path from the agents to the player without ever leaving the navmesh.





     
  8. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Everything that ties directly into the navmesh is in the Navmesh interface script. Just replace all the code in the methods there with your own (or extend the class and apply it to your object/base script) and you should be good to go.
     
    Last edited: Dec 6, 2016
  9. FusionSticc

    FusionSticc

    Joined:
    Mar 16, 2014
    Posts:
    49
    Is there any way to use IK with this? I've currently used PlayMaker and C# script in order to handle IK however, it doesn't seem to be doing anything (Trying to adjust hands to weapon)
     
  10. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    It should be possible in theory- in fact before adapting this for the asset store I did use IK. Make sure whatever you're doing is in LateUpdate though, so it doesn't get overwritten by the animation. Try disabling the RotateToAimGunScript and the animator itself, to enure this isn't a problem with your IK script ad well.
     
  11. FusionSticc

    FusionSticc

    Joined:
    Mar 16, 2014
    Posts:
    49
    Thanks for the quick reply! And it appears all i needed to do was yes, put in LateUpdate. Thanks!
     
  12. Subzeroblack68

    Subzeroblack68

    Joined:
    Apr 3, 2014
    Posts:
    19
    Been using your asset and its great so far through development. But a few questions before I have to worry about them and try to figure them out:

    1) When I lower the AI speed it seems like the barely move their feet as if they aren't completing their animation, like their feet only move a few inches and back. How would I go about fixing it?

    2)Have you ever tried or been asked if your asset will work with the "Final IK" asset? I wanted to add more realistic movement and reactions after the next two phases of my development. (I also just read your reply about creating IK in LateUpdate, but I already have FinalIK and its amazing Xp )

    3) How would I go about adding Dual Pistols? I understand the implementation of a Pistol with both hands on it. But what about alternate shooting with two weapons? I'm assuming I'll most likely have to create a new/custom Behavior...
     
  13. Hokio

    Hokio

    Joined:
    Jun 7, 2016
    Posts:
    3
    Hey there Jack,

    I have a recurring problem with the dynamic cover…I’m trying to create my own scene using the dynamic cover. For example, I’ll create a building in the scene, and then drag some of the C# Cover Nodes to be in the proper positions. However, any node that I touch — literally all I have to do is move it a hair in the scene — the node breaks and the agents will no longer try to use it. I’ve tried dragging and dropping prefabs of Cover Nodes into the scene and that doesn’t work either. I've tried created them from scratch...no luck. I'm not getting any errors or warnings or even Debug Log messages so I'm obviously at a loss as to what's going on. Currently all of my agents simply run straight for the player I've created and attack him non-stop until I kill them. The only strategy they use is their dodging abilities.

    If I start with one of the demo scenes and don't touch anything it will work perfectly without any issues. Even if I'm using Agents that I've created using the scripts, but as soon as I try to move the nodes everything breaks and the agents no longer try to take cover.

    I tried increasing the Distance Behind Cover for my agents like you suggested in the documentation but that didn’t seem to solve my problem. I’m keeping the nodes over the navmesh as well so I don’t think that’s the problem either. I have an AI Controller (tagged properly etc) in the scene as well as properly tagged cover nodes and such but still no joy. No matter what I do I can't seem to fix this at all... Any ideas?

    Cheers,
    Hokio
     
  14. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    1. In the animation script, try modifying the max movement speed to match your agents top speed.

    2. I have not used it myself, but I bet that moving any code from Update to LateUpdate would do the trick there too.

    3. You might be able to pull it off with a second gun script and manually assigning the linked components as needed. That reminds me, I never got around to adding support for multiple barrels to agent weapons.

    So, you're manually adding cover nodes at runtime? Well, the Controller compiles a list of every cover node on Awake. Try simply calling Awake a second time manually, or copy paste the code into a new method barring that. I'm not sure why existing nodes would fall apart if you move them, though. Make sure you call SetPositions() on any node you move at runtime. Feel free to make that method public if you have to. :)
     
  15. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Hi i m beginner with Unity , i got UFPS and Tactical shooter AI. I followed your UFPS integration and others tutorials.
    I have some issues : Grenade that Agent Throw to me dont do any damage on me.
    I dragged a prefab of Team2_Riffle. I have set the target on my player and i have set a layer for terrain, rocks and buildings as "Terrain". I assigned Terrain on Controller. I have put all bullets UFPS in Unity message and i have put all bullets in Tactical IA to layer everything , same for explosive grenade. Should do single Hitbox damage is off on both Grenades.
    Grenade damage the IA agent but not me.
    My bullet can hit the agent and kill him. His bullets can hit me. But Grenade dont do any damage. ( i tryed to change damage amount but nothing ).
    I also tryed to make my own agent like in tutorial. Same Result. Maybe i do something wrong ?
    Please can you help me ? I made a video to show you. Thanks for your help.

     
    Last edited: Dec 22, 2016
  16. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    I suspect that the target script was attached to the player, and not the main camera. That could explain why they are shooting at the player's feet and why the grenades are doing no damage. Also, try removing layers from the grenade explosion's layermask- start with nothing and see if that works, then slowly add as many layers as you can. There might be some object attached to the player in the way.
     
  17. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42

    Thank you so much it work now !
    I had the target on player :) and i have put nothing on grenade and it work :). I dont understand the layermask. I thought i had to add the layer on which the grenade proc effects.

    An another question : Can you explain how i can make agent lose aggro on me and restart their wandering.

    Thanks again !
     
  18. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Glad to hear it is now working! The grenade layermask is a bit different to other ones. It tells the explosion what layers NOT to pass through or effect. This is so that if there is a wall in the way, the explosion will be stopped by the wall. But if you pass it the player's layer, then it will think the player is a wall and not apply damage to it.

    There's a bunch of variables in the target script that affect loss of awareness. I'd list them here, but I don't have access to the project file at the moment, so you'll have to check in the manual. :)
     
  19. FusionSticc

    FusionSticc

    Joined:
    Mar 16, 2014
    Posts:
    49
    I have a few questions:

    1) Would the AI work fine if there is no upperbody mask, but a fullbody mask? I had only realized that my anims for reloading and such require full body (The anim looks pretty weird with the upperbody mask applied. I have not yet tried to remove it)

    2)What is the difference between the Upperbody Idle and Idle for fullbody? Which would I use if question 2 is possible??

    3) Is it also possible to tag covernodes if its high cover or low cover (for Standing cover anim and Crouch cover anim)

    4) Is it possible to use grenade throwing anims?

    Also (Sorry for so many questions, I'm quite the total noob) If my model has incorrect rotations is it still fine if I create the ai (as it creates a gameobj containing Paragon scripts inside)? Or would I have to correct the model by parenting it to an empty gameobj with the correct rotations?

     
    Last edited: Dec 23, 2016
  20. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Hi again :)

    I m trying to create a safe zone , i would like to be safe in my zone 30 x 30. So i have a box collider 30 30 30 and i m inside. The Box Collider is inside a Empty GameObject.

    So i write a script and i attach it to the GameObject:

    void OnTriggerEnter(Collider coll)
    {
    if (coll == vp_LocalPlayer.Collider)
    {
    //TODO
    Debug.Log("SAFE !");
    GameObject.Find("FPSCamera").GetComponent<TacticalAI.TargetScript>().enabled = false;
    }
    }
    void OnTriggerExit(Collider coll)
    {
    if (coll == vp_LocalPlayer.Collider)
    {
    //TODO
    Debug.Log("NOT SAFE !");
    GameObject.Find("FPSCamera").GetComponent<TacticalAI.TargetScript>().enabled = true;
    }
    }

    IA Agent come but after a few sec he attack and kill me

    Why ? .

    Also i created 4 box Colliders forming a square around my safe area , i have set layers and i the matrix collision , i allowed only my player to go inside/outside . So if i disable, i cant exit my safe zone.
    I dont understand why the Agent can enter inside and kill me again :))) ?

    They are incredible !!!! :) I disable script target on my player and i m inside 4 colliders and they still can kill me !

    Sorry for questions , i m begginer with Unity.

    Thanks for your help.
     
    Last edited: Dec 23, 2016
  21. FusionSticc

    FusionSticc

    Joined:
    Mar 16, 2014
    Posts:
    49
    Does the collider have "Is Trigger" checked in the inspector?


    EDITEDITEDIT: Try putting the script on the collider instead.
     
    Last edited: Dec 23, 2016
  22. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    1. Movement animations will not work properly without the mask.

    2. IIRC, they are the same.

    3. If the firing position is in the same x-z location as the hiding position, it is a crouching node. Otherwise it's a standing one. There shouldn't be any ill effects to tagging your nodes.

    4. Yes, either use the included animation controllers or add a dynamic action with the trigger name Grenade using the same dynamic action addition tool as the dynamic objects.
     
  23. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    You need to set the target priority to -1 in order to make the agents ignore it. Simply disabling it won't work. If you want the agents to not enter an area, then you will need to carve your navmesh appropriately- see the Unity docs on the navmesh for more info.

    If the bullets are going through walls, then you will need to add their layer to the bullet's layer mask.
     
  24. FusionSticc

    FusionSticc

    Joined:
    Mar 16, 2014
    Posts:
    49
    Thanks!!
     
  25. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Yes trigger is checked.

    I m trying like this, i have seen the Squared55 Post. I added Obstacle with carving and its ok, agent cant enter inside the safe zone.

    But i still cant trigger correctly to set priority -1 :
    I cant get the Player Object. it give me a _TriggerHandler Instead.

    void OnTriggerEnter(Collider other)
    {
    print("Collision detected with trigger object " + other.name);
    if (other == GameObject.Find("Body").GetComponent<Collider>())
    {
    print("Collision detected with trigger object BODY " + other.name);
    Debug.Log("SAFE !");
    GameObject.Find("Mob 1").GetComponent<TacticalAI.TargetScript>().targetPriority = -1;
    }
    }
    void OnTriggerStay(Collider other)
    {
    if (other == GameObject.Find("Body").GetComponent<Collider>())
    {
    print("Still colliding with trigger object BODY " + other.name);
    Debug.Log("SAFE !");
    GameObject.Find("Mob 1").GetComponent<TacticalAI.TargetScript>().targetPriority = -1;
    }
    }
    void OnTriggerExit(Collider other)
    {
    if (other == GameObject.Find("Body").GetComponent<Collider>())
    {
    print(gameObject.name + " and trigger object BODY " + other.name + " are no longer colliding");
    Debug.Log("NOT SAFE !");
    GameObject.Find("Mob 1").GetComponent<TacticalAI.TargetScript>().targetPriority = 1;
    }
    }

    But that not work .

    If i attach script on My safe zone :
    I have only one debug log message with :

    Collision detected with trigger object _TriggerHandler
    UnityEngine.MonoBehaviour:print(Object)
    SafeZone:OnTriggerEnter(Collider) (at Assets/My Assets/Scripts/SafeZone.cs:23)

    So my player is considered as (_TriggerHandler). I dont understand.
    If anyone can help me about this, would be nice.

    I got my safe zone working because it is smaller than the 4 collider forming a square around the safe zone. So i m the only one that can access to the safe zone. (Matrix collision preference)
    but i want to know why i get the _TriggerHandler instead of my player.

    Thanks for help.
     
    Last edited: Dec 23, 2016
  26. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Well, I unfortunatly can't tell what line that is referring to without code tags around that code. :)
     
  27. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Hi.

    It work now , i used other.transform.parent.GetComponent<Player>();

    Collider that triggered the function was not on the same transform as the Player

    Thank you very much for your help.
     
    Last edited: Dec 26, 2016
  28. FusionSticc

    FusionSticc

    Joined:
    Mar 16, 2014
    Posts:
    49
    Okay, so I'm having a slight problem with grenade throwing. It appears that whenever my agent throws a grenade, his body tilts all the way back, like so any idea whats going on?
     
  29. petercoleman

    petercoleman

    Joined:
    Feb 21, 2016
    Posts:
    477
    Hello,

    I am developing a game using The Realistic FPS Prefab and would like to consider integrating TSAI to potentially improve my AI behaviors. Is there available a Demo, Video or Descriptive Manual which shows how integrate with RFPSP as I would like some more information as to how difficult it might be especially considering that I do have my own bespoke Character and weapon models working under RFPS Prefab and they work fine within that set up having set them up to replicate the RFPS Prefab default ones.

    If there is no demo or video is the TSAI manual available anywhere to read about integrating with RFPSP and using custom Characters and weapons?

    Thank you.

    Peter

    :)
     
  30. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Hi everyone, sorry for the late response. I've been away for the past week. :)

    I'm really not sure why that's happening. Are you using the included grenade throwing animation?

    The instructions included with the package are as follows:

    For RFPS 1.23
    TSAI 1.3

    RFPS CODE:
    In WeaponBehaviour, line 2220, after the if statement in case 0

    Code (CSharp):
    1. else if (hit.collider.gameObject.GetComponent<TacticalAI.HitBox>())
    2. {
    3.   hit.collider.gameObject.GetComponent<TacticalAI.HitBox>().Damage(damageAmt);
    4.   FPSPlayerComponent.UpdateHitTime();//used for hitmarker
    5. }

    In the RFPS ExplosiveObject.cs, line 126, after the if statement in case 0:

    Code (CSharp):
    1. else if (hitCollider.gameObject.GetComponent<TacticalAI.HitBox>())  
    2. {  
    3.    hitCollider.gameObject.GetComponent<TacticalAI.HitBox>().Damage(explosionDamageAmt);  
    4. }
    5.  

    IN TACTICAL SHOOTER AI:
    UNCOMMENT the labelled sections in the
    BulletScript, line 77
    TargetScript, line 498
    ExplosionScript, line 52


    THEN:

    Apply a TargetScript to your player's camera.
    Set the TargetScript's healthScriptHolder to your RFPSPlayer
    Ensure that the AI's BULLET PREFABS have their BulletScript's layermask value set to include the layer the player is on
    Ensure that the AI Controller has it's layermask set to include the objects that make up your level
    Ensure that the Cover nodes have their layermasks set to include the objects that make up your level
    Ensure that the AI's EXPLOSION PREFABS have their layermasks set to include the objects that make up your level

    ----

    For whatever reason, upon import, Unity removes any animation called "run" from all of the RFPS animators which causes a chain reaction and basically causes the whole game to fall apart.
    You'll need to manually replace these upon import.

    RFPS changes the default timescale to 0. Make it 1 or add an RFPS player to the scene to make it work.

    ---
     
  31. FusionSticc

    FusionSticc

    Joined:
    Mar 16, 2014
    Posts:
    49
    I'm currently using a custom grenade throwing anim. However, if i set the rotation limits of the "spine to rotate" to 0,0,0 it appears the anim works normally, however of course the body can't rotate anywhere.
     
  32. FlyTroll

    FlyTroll

    Joined:
    Jul 20, 2014
    Posts:
    8
    We need more tutorial videos :)
     
  33. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    In the base script, try increasing the values under Grenade parameters.
     
  34. petercoleman

    petercoleman

    Joined:
    Feb 21, 2016
    Posts:
    477
    Hi Thanks for that. Much appreciated.

    I will need to update the AI in my game sometime and TAI looks to be fine. I will probably wait for the next update to RFPSP before attempting this as if and when the next update comes - perhaps around April hopefully I have to get that working without breaking my game and also consider updating my Unity version too at the same time so that all moves forward together....

    Can you tell me if integrating TAI - removes the RFPS prefab influence (all features) in total or does it integrate leaving some or all other features other than the AI behaviours intact? if that makes any sense at all?

    Thank you very much for your help.

    Regards

    Peter
     
  35. FusionSticc

    FusionSticc

    Joined:
    Mar 16, 2014
    Posts:
    49
    Thanks! It seems the anim is working normally
     
  36. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    TSAI integration essentially just involves making it so the two systems can damage each other. Nothing else should be affected.

    For further clarification, the values should sum to the length of the animation- one is the time until the grenade is released from the hand, and one is the remainder of the time.
     
  37. FusionSticc

    FusionSticc

    Joined:
    Mar 16, 2014
    Posts:
    49
    Ah, I see! Thanks for the help again
     
  38. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Hi, i need your help again please.
    Sorry for my questions , i m beginner with unity.

    1. On bullet script there is a hit and miss effect. When Agents hit me , i see the "miss effect" , should i add the hitbox on each part of my UFPS player to see the "hit effect" ? If not , how i can do ?

    2. I m trying to add loot on corpse. But when my raycast hit ragdoll bodies, my trigger wont work. I m not sure but i think its a collider issue. How can i do to have a box collider on agent when they die please ? If not, what is the best way to make the coprse lootable ?

    3 I want to know if its possible to decrease the amount of damage done by bullets through code. I have a stat Shield , and when this stat increase i would like to take less damage. Not sure this is the right way to do it.

    Thank you for your help.

    Happy new year ! :)
     
    Last edited: Jan 10, 2017
  39. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Happy New Year! :)

    1) If an object with the hit tag is struck, the hit effect will be played.

    2) You can add the OnAIDeath() method to any script on your object to execute code when your agent dies. Just be warned that the main AI object is destroyed on death, so make sure to put anything on the ragdoll or as it's own separate object.

    3) You'd want to add any damage modifiers in whatever code you use to receive damage on your player.
     
  40. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Thank you very much for replying. I will try that !

    Edit :

    the hit effect tag is "HitBox".
    I added "HitBox" as tag on all parts of my player body in hierarchy and also for my player itself.
    I still have the miss effect when IA hit me , i lose hp but i have the miss effect.
    How can i fix this please ?

    Thanks again :)
     
    Last edited: Jan 13, 2017
  41. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    The object the bullet is hitting does not have the hit tag. Perhaps it is being created at runtime.
     
  42. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Hi.

    Still Trying for the hiteffect, maybe should i add tag on object with target script ? (UFPS Camera ?) Because i added tags on all colliders on my UFPS player and it wont work.

    Also trying to make corpse lootable. If i use a collider even with "istrigger on" on ragdoll , i m unable to damage the agents.
    So i tryed like you said, i created a script to add a collider component to the ragdoll when agent die. But that wont work if i add it on ragdoll. It work if i add it on AI agent. But AI agent is destroyed. Please how can i do it ?


    namespace TacticalAI
    {
    public class SpawnCapsuleCollider : MonoBehaviour
    {

    public void OnAIDeath()
    {
    Debug.Log("here");
    CapsuleCollider c = gameObject.AddComponent<CapsuleCollider>();
    c.height = 2;
    c.radius = 0.7f;
    c.center.Set(0, 1, 0);

    }
    }
    }

    Sorry for the questions , i m begginer.
    Thanks for your help.
     
    Last edited: Jan 14, 2017
  43. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    The issue is that the stuck object does not have the tag. Try pausing the game at runtime to find the object, it may be one that is manipulated or created at runtime. Alternatively, try changing the hit tag to the tag of the struck object if you cannot change it.

    Because the ragdolls destroy themselves after enough time, I recommend simply instantiating a loot pick-up. As it stands, that script will either not fire, because it is not on the main AI object, or it will fire, but the created capsule will be instantly destroyed, along with the main AI object. You will need to add the capsule collider to the ragdoll (a separate object).
     
  44. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Hi. Thank you.

    I fixed both issues.

    For the Hit/Miss effects :

    In UFPS, there is a trigger created on player hierarchy at run time with "Vp_domageTransfer" on it.
    I added a line in the script OnStart()

    Code (CSharp):
    1. m_Collider.tag = ("HitBox");
    Now that works.

    For the Loots on corpses :

    I used OnAiDeath() method to instanciate a crate.

    Code (CSharp):
    1. namespace TacticalAI
    2. {
    3.     public class LootCrateSpawner : MonoBehaviour
    4.     {
    5.         private GameObject m_soldierRagdoll;
    6.         private GameObject m_soldierPelvis;
    7.         public GameObject m_lootPrefab;
    8.  
    9.         private void Awake()
    10.         {
    11.             m_soldierRagdoll = transform.FindChild("Soldier_Ragdoll").gameObject;
    12.             m_soldierPelvis = m_soldierRagdoll.transform.Find("Pelvis").gameObject;
    13.         }
    14.  
    15.         public void OnAIDeath()
    16.         {
    17.             GameObject.Instantiate(m_lootPrefab, m_soldierPelvis.transform.position, Quaternion.identity, m_soldierRagdoll.transform.parent);
    18.  
    19.         }
    20.     }
    21. }
     
    Last edited: Jan 22, 2017
  45. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Hi again.

    I m trying to make a melee AI agent. I would like to add a monster without gun. What is the best way ?
    I followed the quick setup tutorial. It work, monster attack me, make damage and take damage but i m not sure how to add "dying" and "hit" animations and how to trigger these animations correctly. Also i would like to add sounds when monster hit me. (no bullet sounds).

    For my monster, i unchecked"gun script" and "rotate to aim gun script" to avoid warning message about guns and bullet. Not sure i can do that.
    Please how can i do to avoid warning and error message when doing only melee with no gun ?

    When i click show optional Animations in animation controller made with ai wizard, there is only a few so i did add paragon dynamic action, i added "dying" and "hit" animations from my monster.

    on a mob without AI agent, i intercept damage like this to play animations ( i m using UFPS ).

    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. public class MyDomageHandlerMonster : vp_DamageHandler {
    6.   private Animator _animator;
    7. private TacticalAI.HealthScript _healthScript;
    8.   protected override void Awake()
    9.   {
    10.   base.Awake();
    11.   _animator = GetComponent<Animator>();
    12.   }
    13.  
    14. public override void Damage(float damage)
    15.   {
    16.   if (CurrentHealth > 0)
    17.   {
    18.   base.Damage(damage);
    19.   Debug.Log("hit ! ok");
    20.   _animator.Play("HitFront", 0, 1.2f);
    21.   _healthScript =GameObject.Find("Mob Ratskin 1").GetComponent<HealthScript>();
    22.   //_healthScript.health -= damage;
    23.   _healthScript.Damage(damage);
    24.   }
    25.  
    26.   }
    27.  
    28.   }
    29.   public override void Damage(vp_DamageInfo damageInfo)
    30.   {
    31.   base.Damage(damageInfo);
    32.   Debug.Log("hit ! ok");
    33.   _animator.Play("HitFront", 0, 0.2f);
    34.   }
    35.   // Use this for initialization
    36.   void Start () {
    37.  
    38. }
    39.  
    40. // Update is called once per frame
    41. void Update () {
    42.  
    43. }
    44. }
    45.  
    I get this this message :

    Warning (PistolBullet(Clone) (vp_FXBullet)) Target object has a vp_DamageHandler. When damaging it with DamageMode: 'UnityMessage' or 'Both', you probably want to change 'DamageMethodName' to something other than 'Damage', or too much damage might be applied.
    UnityEngine.Debug:LogWarning(Object)
    vp_Bullet:TryDamage() (at Assets/UFPS/Base/Scripts/Gameplay/Combat/vp_Bullet.cs:269)
    vp_Bullet:DoHit() (at Assets/UFPS/Base/Scripts/Gameplay/Combat/vp_Bullet.cs:183)
    vp_Bullet:TryHit() (at Assets/UFPS/Base/Scripts/Gameplay/Combat/vp_Bullet.cs:157)
    <TryHitOnEndOfFrame>c__Iterator0:MoveNext() (at Assets/UFPS/Base/Scripts/Gameplay/Combat/vp_Bullet.cs:340)

    I would like to know how i can intercept damage without having to use vp_damageHandler.

    For the Dying animation , i had to use the OnAiDeath method and had to enable the disabled animator

    Code (CSharp):
    1.  public void OnAIDeath()
    2.         {
    3.             if (this.name != "Mob Ratskin 1")
    4.             {
    5.                 GameObject.Instantiate(m_lootPrefab, m_soldierPelvis.transform.position, Quaternion.identity, m_soldierRagdoll.transform.parent);
    6.             }
    7.  
    8.             else if (this.name == "Mob Ratskin 1")
    9.             {
    10.                 GameObject.Instantiate(m_lootPrefab, m_soldierPelvis.transform.position, Quaternion.identity, m_soldierRagdoll.transform.parent);
    11.                 _animator.enabled = true;
    12.                 _animator.Play("DyingB", 0, 1.2f);
    13.                 _animator.Play("DyingB", 1, 1.2f);
    14.                 //_animator.enabled = false;
    15.             }
    16.         }
    If i uncomment the line _animator.enabled = false , it dont play the dying animation till the end so my monster is stand and freeze.

    Not even sure this is the right way to do what i want to do.

    I have also an another problem, i use multiscene (additive). I cant drag my player in the Target Script "Health Script Holder" because my player is in the main scene and ennemies are in another scene. So i need a script to initialise "Health Script Holder" at launch. I have no idea how i can do that ;( (Maybe i can drag a prefab of my player instead of the player it self ? )

    Sorry for beginner questions :)

    Thanks for your help. Sorry for my poor English.
     
    Last edited: Jan 28, 2017
  46. ApexofReality

    ApexofReality

    Joined:
    Feb 14, 2016
    Posts:
    102
    Can you release another demo the demos seem to not be working
     
  47. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    Hit animations can be added by filling in the Stagger parameter in the animation controller creation wizard (make sure you open the additional animations dropdown). It will automatically be triggered when the agent takes enough damage in a single hit.

    What error messages are you getting?

    The HealthScriptHolder on the player's target script needs to reference the player's health script. Vice-versa for the enemies. In other words, each agent only refrences it's OWN prefab. So, there should be no issues for cross-scene stuff.

    That's (more or less) what I would do. If it works, keep it. :)

    Unfortunately, my hosting service ended support for webplayer demos recently.
     
    Last edited: Jan 29, 2017
  48. ApexofReality

    ApexofReality

    Joined:
    Feb 14, 2016
    Posts:
    102
    Do you know if this is still compatible with easy weapons?
     
  49. squared55

    squared55

    Joined:
    Aug 28, 2012
    Posts:
    1,818
    I can't recall ever adding Easy Weapons support in the first place, although the Easy Weapons developer may have added support on his end. You'd have to ask them. :)
     
  50. jjshaw_2017

    jjshaw_2017

    Joined:
    Jan 29, 2017
    Posts:
    1
    Hello
    I have created an agent successfully and when I put him on the demo maps it seems to work totally fine and as expected, however when I put him on my own map and with my own character controller (custom controller, not one of the out of box supported packages), they will just drift in a straight line but if I walk directly in front of him (literally have to make physical contact), that's when he will see me and begin behaving as expected.
    He shoots and deals damage, but he also just directly runs at me in a straight line rather than doing anything, however my primary concern is the fact that he does absolutely nothing until I am an inch from his face - with his field of view at 250 and distance at 99999.