Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third person cover controller

Discussion in 'Assets and Asset Store' started by EduardasFunka, May 23, 2017.

  1. redoxoder

    redoxoder

    Joined:
    May 11, 2013
    Posts:
    74
    hi, missing 11 and 14 vidéo on youtube ..
    ;)
     
  2. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Yeah! 11 and 14 are missing.
     
  3. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Tutorial 7 and 8 are same.
    This isn't good.
    And you haven't explained how to make sniper go invisible while in scope.
     
  4. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    it's time to say : Chill and relax i delayed my game 6 months because of the bugs on this asset.
    but to say that this asset did not help me to reduce the development time by years i will be an ungrateful liar .
    i think the dev is doing his best to make this asset great .
    some patience and he will fix the tuto and the bugs
    some of you did not experience the 1.3 ver performance bug , or the weird AI ... the asset have gone thru alot of work and fixes , please do not pressure the dev into abandoning the asset , if i was him . i will be long gone after 3 months of release. i urge all of you to subscribe to his patreon .. 5 -10 USD is not much .
    and Email him your problems or posting here ... just don't rant about it ...
     
    uni7y, redoxoder, Camelot63RU and 2 others like this.
  5. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Thanks for the support :)
     
  6. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    317
    Here's a bonus. For those paying attn:

    A few days ago someone was showing a video with realistic shell ejection. They said they would share the script...someone also asked about the sounds for the shells. Well here is how I get mine to play:
    You put this on your shell. The part with the particle system that tosses the shells.
    Essentially its using the existing colliders and plays a sound when it smacks something.


    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [RequireComponent(typeof(AudioSource))]
    5.  
    6. public class PSGShellSound : MonoBehaviour
    7. {
    8.     public AudioClip soundEffect;
    9.     AudioSource audio;
    10.     private int SoundCount = 0;
    11. //Sets a int to 0
    12.  
    13.     void Start()
    14.     {
    15.         audio = GetComponent<AudioSource>();
    16.     }
    17.  
    18.     void OnParticleCollision()
    19.     {
    20.         if (!audio.isPlaying && SoundCount < 1)
    21. //Checks if the audio is playing and the SoundCount is Less that 1. If it is Skip and don't do anything, else play the sound, Had to add this or it would be stupid and play repeatedly till it despawns. Because god forbid oneshot mean ONE SHOT...
    22.         {
    23.             audio.PlayOneShot(soundEffect, 1.0F);
    24.             SoundCount++;
    25. //Plays sound then Changes the counter
    26.         }
    27.         else return;
    28.     }
    29. }
    For the sound I recommend using 'Weapons of Choice FREE - Komposite Sound'
    He put in long shells and short shells. so you have 1 sounds for each type. theres also reload sounds in there I think. and some material impact audio. It also happens to be free.

    Here is the video of it in action:
     
    Last edited: Oct 8, 2018
  7. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Thanks for the report. 8 video fixed 14 uploaded. 11 video will be recorded again today (lost footage.)
    we do not have the ability to hide mesh now. in our case, our UI hide it. Can you show me what problems you get?
     
    Paul-Swanson likes this.
  8. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Scope.PNG

    Check this out. That sniper is visible on the left while with cowboy sniper, it automatically gets invisible and the layer of sniper mesh of cowboy changes to SCOPE.
    Note: If I manually change layer of my own sniper mesh to SCOPE, it becomes invisible.
     
    EduardasFunka likes this.
  9. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    317
    Seems like an easy solution. You found half if it on your own. I'll see if I can find the scope function. Just need to find where it happens then toss I .Some code that changes the layer to something like scoped the .changes it back when you release the scope.
     
    EduardasFunka likes this.
  10. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    when you change to sniper mode , make the sniper rifle on that layer
    1. gameObject.layer = LayerMask.NameToLayer("YourLayerName");
      or gameObject.layer = 5 // the number of the layer if you know it
    tell the camera to ignore the layer on the settings.(if new project)
    and on sniper exit gameObject.layer = default .. or whatever
     
    Paul-Swanson likes this.
  11. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    317
    Exactly! That should definitely do it. Sorry I just wasn't able to find the exact spot to add that code. But what Rahd said should definitely work.
     
    Rahd likes this.
  12. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    123
    How Add Custom Action to the Main Player.
     
  13. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Thanks, I know how to do that with my own script but the question is, Why does cowboy's sniper auto hides in scope while my own sniper doesn't. I know the line of code which does that.

    In ThirdPersonCamera scipt on line 285:

    Capture.PNG

    This is the line responsible for hiding sniper mesh.
    I don't know why it doesn't work with my own sniper.
     
  14. HasnainKhan

    HasnainKhan

    Joined:
    Nov 8, 2016
    Posts:
    11
    Hi there, I love your asset and I intend to buy this asset but I need to add RPG and grenade launcher is there any possibility to add new weapons?
    And how hard it is, I am a new developer.
     
  15. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Hi,
    I am not sure how fast you need those features. If you want them now then you need to code them yourself and add additional animations how you carry those weapons, how those weapons look in cover mode etc.

    if you can wait 3-6 months we probably will add them later.
     
  16. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Nice dager fight!
     
    Dawar likes this.
  17. HasnainKhan

    HasnainKhan

    Joined:
    Nov 8, 2016
    Posts:
    11
    If I buy your asset will you help me in putting new weapons? Will you point out where I have to modify the code to get it working.?
     
  18. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Character Motor works with the concept we named as BodyValue, which is pretty much an index into available poses. Adding a new BodyValue involves adding a new blend tree inside the animator. Also, for nicer blending we have created a separate animator parameter for each value. You'd need to create a new one, called "BodyValue6", if it's added on top. Add code where such parameters are adjusted.

    BodyValue is calculated inside the CharacterMotor's getWeaponProperties(). It uses weapon type to determine which body value to use.

    Another animator parameter used is "gunType", calculated in CharacterMotor's private property also called "gunType". Look for the switch statement there and add a line for your new weapon type.

    For this new weapon type, you need to add a new animator layer similar to currently available "Pistol" and "Rifle" to show equip/unequip/reload/aim animations. Keep note, however, that these animator nodes must have behaviour scripts (like EquipAnimatio, ReloadAnimation) attached to them.

    We also have an enum called HitType that tells what caused each hit. It's not used in our demo code. However, if you need to have it, it's handled inside BaseGun's fire() method.

    Usually, I don't give lessons on how to add a specific feature. I don't know how good you with unity.
    Also I have a patreon, where customers can subscribe and buy feature they need.

    Goodluck.
     
    bwv1056 and AshyB like this.
  19. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    uni7y likes this.
  20. redoxoder

    redoxoder

    Joined:
    May 11, 2013
    Posts:
    74
    hi,
    what was fixed in 1.61b ? thanks
     
  21. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    third person cover scene restored
     
  22. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
  23. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    123
    Stealth Killed
     
  24. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    317
    1 more bonus script sound related. I noticed there was a lack of sound for the material impacts.So made a script for you. You put this on the Impact Shard Prefab you would use instead of the HitAnythingParticles or BloodParticles if you chose too.

    Here it is:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [RequireComponent(typeof(AudioSource))]
    6. public class PGSSoundOnImpact : MonoBehaviour
    7. {
    8.     public AudioClip soundEffect;
    9.     AudioSource audio;
    10.     private int SoundCount = 0;
    11.  
    12.     void Start()
    13.     {
    14.         audio = GetComponent<AudioSource>();
    15.     }
    16.  
    17.     void Update()
    18.     {
    19.         if (!audio.isPlaying && SoundCount < 1)
    20.         {
    21.             audio.PlayOneShot(soundEffect, 1.0F);
    22.             SoundCount++;
    23.         }
    24.         else return;
    25.     }
    26. }
    You can see it in action in the following video as well as the shell sounds from my previous one.

    If anyone's curious my effects are these 2 packages:
    https://assetstore.unity.com/packages/vfx/particles/impacts-and-muzzle-flashes-57010
    https://assetstore.unity.com/packages/vfx/particles/fire-explosions/realistic-explosions-pack-54783

    Both are really nice, 1st ones Muzzle Flashes and Bullets impact affects.
    The second is explosions both sprite and 3d Volumes.
    A bit of work needed to be done to align them to your POV though, so its not a super plugin play solution but its pretty darn close.



    @EduardasFunka
    If you wish to use either of my sound scripts please feel free. Id rather you keep busy maintaining the asset than worry about silly cosmetic things like this. So if it makes your life easier by all means, please use it.
     
    Last edited: Oct 10, 2018
  25. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    ZOMBIES!!! Yes thank you!!!
     
  26. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Damn! Thats great!!!!
     
  27. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Very nice. we need a wiki page for the amazing stuff you guys making and sharing. Anyone good with web and administrating?
     
    Camelot63RU likes this.
  28. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170


    I used your code and it works perfectly - so thanks! However I'd like to have the play "uncrouch" if he jumps, falls, runs, etc.. right now he goes back to crouch after a jump and it looks odd.

    I'm not very good with code (i use playmaker mostly) so I can't figure it out myself :)

    -rich
     
    jnbbender likes this.
  29. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    Hello

    How can I change the foot step sounds based on the walking surface?

    Thanks,
    rich
     
  30. NickNovell

    NickNovell

    Joined:
    Apr 27, 2017
    Posts:
    51
    Hello,
    I bought your asset today and it looks great. Although I have to say that a pickup feature is a must on this king of assets (health, usables, weapons etc). Also bullets have to interact with other objects on the scene, impacts on different surfaces, break or move rigidbody objects etc. (Anyone knows how to move things when we shoot them)?

    Keep the good work. Thank you.
     
  31. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    317
    Yes - Anyone knows how to move things when we shoot them
    The way you solve this is on your bullet prefabs, assign a mesh with a box collider, Not just a trigger volume... then put a rigid body on it. He had it set to a Long Cube then disabled the mesh Renderer. Turn off gravity so movement is only script based. What ever you want to hit and react with simply needs to have a mass to it. Such as a door on a hinge. I experimented on that with a door hinge. I came up with this working process however i haven't made it across the board yet. So I don't have a working example for you.
    I have not yet found a way to make grenades do the same thing. But that's on my todo list.
    I'm thinking a rapidly growing collider with heavy mass...but we'll see.

    As far as a drop system, I have one in another project that I'll adapt to this one. It works by assigning an array of object you want said enemy to drop. In the AI script you simply need to send a message to the drop script and it tosses what ever you want them to drop into the air or on the ground.
    He did already include a basic inventory script for ammo capacities. They simply are not displayed on the HUD yet. I think he set everything to 10,000 by default. Should be easy enough to make them show up, with a little bit of poking.

    I know @AshyB managed to make it work with InventoryPro I think...I asked if angel(i thought it was angel_m but apparently not, Iv corrected that) would share the bridge but i never got a response. So at the very least we know its possible, I haven't really looked into it myself as I was hoping the bridge might have been shared eventually, as well as the setup.

    @EduardasFunka
    This brings up a good chance to ask this. Is there a equivalent to OnDead() or something for the AI? If so where? That would make it very easy to Adapt my enemy drop script. -- Figured out the OnDead() bit see below script.

    However next question.
    Its pretty obvious how to alter the text field showing the ammo counts, but what is not easily figured out if how to make it so its like this instead: Current Loaded Ammo / Total Ammo of equipped type. I have found myseld unable to use BulletInventory as a text variable. I checked in Basegun and its certainly not there. So I added it manually but it doesnt go down. SO now I'm not sure if i did something wrong or if the LoadMagazine just ins't reducing the InventoryCount.
     
    Last edited: Oct 11, 2018
    NickNovell and redoxoder like this.
  32. redoxoder

    redoxoder

    Joined:
    May 11, 2013
    Posts:
    74
    very good
    a tuto how to do this will be nice
    thanks
     
  33. NickNovell

    NickNovell

    Joined:
    Apr 27, 2017
    Posts:
    51
    Thank you very much for your answer. Looking forward for your script.
     
  34. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    I’m having an issue with AI vs Navmesh handling. I have AI on a platform or rooftops, they can freely move but don’t jump or fall. I’m baking my navmesh so there’s a unwakable section all around the platform but AI seems to be ignoring it and just falling.

    If I’m adding a Navmesh agent to AI it works but animation doesn’t switch to idle or changing direction. The AI keep trying to walk in same direction without going anywhere.

    Any of you experimented something like that ?

    Thx
    Chris
     
  35. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    317
    Here is the script for dropping items that can potentially be used as pickups:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4.  
    5. //10/22/17 v1.01 - Script created to allow the enemies to drop items on death for the player to pickup
    6. //10/23/17 v1.02 - Update Array of items added, and scatters in defined range -- Still planning on using add force...eventually
    7.  
    8. //Using CoverShooters name space.
    9. namespace CoverShooter
    10. {
    11.  
    12.     //Defining My class
    13.     public class PGS_CoverShooter_EnemyDrops : MonoBehaviour
    14.     {
    15.         //Gameobject Array
    16.         public GameObject[] _Items_To_Drop;
    17.      
    18.         //Just for setting Ranges
    19.         public float _SpawnX=1f;
    20.         public float _SpawnZ=1f;
    21.         public static float _Range_To_Spawn_X = 1f;
    22.         public static float _Range_To_Spawn_Z = 1f;
    23.         public static float _Height_To_Spawn = 1f;
    24.  
    25.         // Need to Cache the Transform Position, or it trys to spawn at a transform that no longer exists
    26.         //and you'll get a failed script and errors in runtime
    27.         private Transform Cached_Position;
    28.  
    29.         //Can create an height offset here to keep things out of the floor/ceilings - Public for easy access
    30.         public Vector3 Offset = new Vector3(0, _Height_To_Spawn, 0);
    31.  
    32.         //Need this to grab and set random positions
    33.         public void Update()
    34.          {
    35.          //Assigning float this way since not visible in the inspector
    36.          _Range_To_Spawn_X = _SpawnX;
    37.          _Range_To_Spawn_Z = _SpawnZ;
    38.          Offset = new Vector3(Random.Range(_Range_To_Spawn_X, -_Range_To_Spawn_X), _Height_To_Spawn, Random.Range(_Range_To_Spawn_Z, -_Range_To_Spawn_Z));
    39.          Cached_Position = this.transform;
    40.          }
    41.  
    42.  
    43.         //When The Enemy Agent kicks the bucket do this
    44.         public void DropPickup()
    45.         {
    46.          foreach (GameObject i in _Items_To_Drop)
    47.          {
    48.           GameObject EnemyDrop = Instantiate(i, Cached_Position.transform.position + Offset, Cached_Position.transform.rotation) as GameObject;
    49.           MoveRandomlyViaOffset();
    50.           EnemyDrop.transform.position = transform.position + Offset;
    51.          }
    52.         }
    53.  
    54.         //Need this to regenerate the random position for each object in the array
    55.         public void MoveRandomlyViaOffset()
    56.         {
    57.          _Range_To_Spawn_X = _SpawnX;
    58.          _Range_To_Spawn_Z = _SpawnZ;
    59.          Offset = new Vector3(Random.Range(_Range_To_Spawn_X, -_Range_To_Spawn_X), _Height_To_Spawn, Random.Range(_Range_To_Spawn_Z, -_Range_To_Spawn_Z));
    60.         }
    61.     }
    62. }
    And to make this work when they die you need to add a few things to CharacterHealth.cs
    On Line 70 add this right under private CharacterMotor _motor;

    So it appears like this:
    private CharacterMotor _motor;
    public PGS_CoverShooter_EnemyDrops _enemyDrops;

    in the awake method also add
    _enemyDrops = GetComponent<PGS_CoverShooter_EnemyDrops>();

    And finally in public void OnDead()
    add this right after Died();
    _enemyDrops.DropPickup();

    NickNovell one thing to think about is this doesn't let you pick it up, this only drops it.I'll work on actually adding the pickups later but this is 1/2 of it. So what I did was duplicate the pistol removed all the scripts, added a few colliders and a rigidbody. Then resaved it as Droppable Pistol.
    On the Enemy you put the droppables script on it, set the array to 1. Dragged my new pistol prefab in. Tested and sure enough guy drops it.

     
    Last edited: Oct 11, 2018
    Toby31, Lay84, pushingpandas and 2 others like this.
  36. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    123
    Damage Indicator
     
  37. NickNovell

    NickNovell

    Joined:
    Apr 27, 2017
    Posts:
    51
    Many people are giving so much to the community and we appreciate that. You are one of them. So thank you. This is a good start and a big help for me that I am a designer and not a programmer. I am trying to learn tho :) I hope in the next updates we will see these features so we can have a more realistic gameplay to our products. Thanks again for your valuable help.
     
    Paul-Swanson and Camelot63RU like this.
  38. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Here what I was talking about. Default AI not following baked area.

    https://vimeo.com/user90500659/review/294611966/b391bddc2c

    I can replicate the problem with untouched 1.6 version.

    The debug rays you can are from AIUtil.cs - NavMesh.CalculatePath function as below :


    NavMesh.CalculatePath(source, target, NavMesh.AllAreas, path);

    switch (path.status)
    {
    case NavMeshPathStatus.PathComplete:
    Debug.DrawLine(source, target, Color.green, 30.0f);
    Debug.Log("Complete");
    break;

    case NavMeshPathStatus.PathPartial:
    Debug.DrawLine(source, target, Color.yellow, 30.0f);
    Debug.Log("Partial");
    break;

    case NavMeshPathStatus.PathInvalid:
    Debug.DrawLine(source, target, Color.red, 30.0f);
    Debug.Log("Invalid");
    break;
    }
     
    Last edited: Oct 11, 2018
  39. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    123
    Update footstep System
    I will make Tut for this in weekends.
     
  40. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    lovely lovely !! thank you please more
     
    Camelot63RU and pushingpandas like this.
  41. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    i think you need a navmesh bridge ?
    yeah to fix all the navmesh issues , disable the enemy when he is away of the screen and bake navmesh in real time some who baking it again stops all the nav issues https://github.com/Unity-Technologies/NavMeshComponents
     
    f1chris likes this.
  42. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Thanks for the idea.

    I did a lot of testing with Navmesh Components and the Navmesh Modifier for different Navmesh agents ( I love that github). But for some reason it creates more jumpers than the delivered navigation functionality. I still need to understand the why !!
     
  43. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Hi, Can you give me the link for this stealth kill animations (Killing and Being Killed animations) please?
     
  44. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    123
    download it from www.mixamo.com
     
  45. NickNovell

    NickNovell

    Joined:
    Apr 27, 2017
    Posts:
    51
    Hello. Is this going to work for the terrain index textures too?
     
  46. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    I am unable to find them. What should I search for? The keyword for searching?
     
  47. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
     
  48. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    I'd like to have my Enemy AI:

    - Have random idle animations
    - Have random chatter
    - Say something when they spot player, loose player, searching for player

    Any suggestions? Are there any global vars I can check for AI status?

    thanks,
    rich
     
  49. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    Also is there a way to set a delay for the Enemy AI between spotting the player and starting to shoot?

    thanks,
    rich
     
  50. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    123