Search Unity

Third person cover controller

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

  1. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    123
    you should change in ThirdPersonInput.cs Class like that
    Code (CSharp):
    1.  public class ThirdPersonInput : MonoBehaviour
    2.     {
    3.    public bool isPause=false; // add this variable
    4. private void Update()
    5.         {
    6.             if (Disabler != null && Disabler.activeSelf && !isPause) // change here
    7.                 return;
    8.  
    9.             UpdateCamera();
    10.             UpdateTarget();
    11.             UpdateCustomActions();
    12.             UpdateMovement();
    13.             UpdateWeapons();
    14.             UpdateReload();
    15.             UpdateRolling();
    16.             UpdateAttack();
    17.             UpdateGrenade();
    18.             UpdateCrouching();
    19.             UpdateClimbing();
    20.             UpdateCover();
    21.             UpdateJumping();
    22.  
    23.             _controller.ManualUpdate();
    24.         }
    25. }
    now when you open menu you just get ThirdPersonInput.cs class and make isPause=true.and when menu close make it True.isPause=false
    I hope its Help you
     
  2. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    @EduardasFunka Are you ever going to have a character setup wizard instead of having to tediously setup from an existing character?
     
    uni7y and jnbbender like this.
  3. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    123
    yes same problem
     
  4. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    318
    Woot! Thx
    I needed to change this
    Code (CSharp):
    1. (Disabler != null && Disabler.activeSelf && !isPause) // change here
    2.                 return;
    To this instead
    Code (CSharp):
    1. (Disabler != null && Disabler.activeSelf || isPause == true) // change here
    2.                 return;
    And it worked
     
    Last edited: Dec 7, 2018
  5. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    its in plans for quality of life features. But it's not a high priority now. We thought you guys will customize it for your game.
     
  6. uni7y

    uni7y

    Joined:
    Jul 23, 2012
    Posts:
    287
    maybe you should do a poll about this? I think more people are interested than you think ;) myself for that matter i'm very interested
     
  7. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    I did that on my patreon page.
     
    Camelot63RU and uni7y like this.
  8. uni7y

    uni7y

    Joined:
    Jul 23, 2012
    Posts:
    287
    oopppsss... I missed that :oops: Voted for "Quality of life (speedup)"
     
  9. StaticWave

    StaticWave

    Joined:
    Aug 21, 2016
    Posts:
    17
    I started a character setup wizard yesterday. Here is the start of it. Feedback and help welcome: https://github.com/kristiandelay/Third-Person-Cover-Shooter-Template-Character-Tool



    I plan on adding attaching of weapons next, they will be populated from a user generated prefab weapon list.

    once that is finished, i will add an ai checkbox to automate adding the ai scripts.

    I havent gone to bed yet, i wrote this over an all nighter so sorry for lack of better error handling.

    Suggestions comments welcome.

    Cheers enjoy!
     
    SteveB, uni7y and satchell like this.
  10. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    318
    Hah very nice.
     
    StaticWave likes this.
  11. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Don't like the pink. JK
     
    StaticWave likes this.
  12. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    I was hoping to have a little help on this script and maybe we can all use it.
    The camera clips through the players head when it gets too close and therefore does not look too appealing. The attached script is supposed to create a Lerped fade based on the camera distance to the player, instead the player just quickly fades out. The video shows what's happening and the script which shows a feeble attempt at the Lerp. Sorry about the jitter, that's the recording software.



    In the script
    "FadeAt" represents the distance at which the camera is supposed to begin its fade.
    "MinOpacity" represents the minimum Alpha value that will be Lerped to (i.e. 0 == invisible)

    Note: This script works good with the Standard shaders just not the Legacy ones.

    Any ideas, help would be great.
     

    Attached Files:

    f1chris and StaticWave like this.
  13. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    318
    I think what's happening here is with your alpha unless you present it as a fraction it jumps from 0 to 1 so if you want it tonlerp you need to have it hold a value like this col.a = .1f/255f then similar on your max.
    I don't know why Unity does it this way but I had to do that as a work around for my night vision script. I'm on my phone so I can't come up with a working example but give that a shot
     
  14. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Still working it. Just making things worse though; this is more of a CPU hog than anything. There should be a shader solution I am just no good with 'em
     
  15. StaticWave

    StaticWave

    Joined:
    Aug 21, 2016
    Posts:
    17
    Bahah i knew someone was gonna say something about the pink
     
    uni7y likes this.
  16. camsha

    camsha

    Joined:
    Nov 18, 2013
    Posts:
    11
    Hi, guys. I recently bought this asset and I am enjoying it so far. I am using a mobile character and controls in a nearly empty scene. When I drop a zombie enemy prefab in, he seems to behave normally until he sees me. At this time he closes to within about 4 meters and then circles me forever. His FighterBrain sets the state to assault and on the next frame it goes to circle. When circle finishes, this repeats - back to assault for one frame and then circle. In the Prototype Scene that comes with the asset, the zombies function normally. I tried using the cowboy from that scene with a zombie from that scene in a new scene, with mobile controls, and I still just get circling. Any ideas? Thanks.
     
  17. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    did you rebake the navmesh ? if that won't work try the other way around
    try to import the mobile player and controller to the zombie example scene
    1-open the zombie example , delete the player prefab and all the unwanted stuff
    2- drag and drop the mobile example scene in the Hierarchy menu
    3-grab the mobile controlls and UI and the player and drop them in the zombie example scene

    it could be anything from player tag , to actor side script ... ect
     
    camsha likes this.
  18. camsha

    camsha

    Joined:
    Nov 18, 2013
    Posts:
    11
    In my research through this forum, I saw this:
    "We are not using Navmesh Agents as those have their own movement controls and physics."
    And somehow I read that as "We are not using navmeshes..." so I didn't go down that path (pun not intended).
    Anyway, yes, I just needed a navmesh baked. Thanks for the quick reply. I guess I am used to navmesh agents that will warn you if there is no navmesh and they won't walk around at all. These guys seemed to work fine until they got close to my character.
    Thanks again.
     
    Rahd likes this.
  19. Blackghost

    Blackghost

    Joined:
    Oct 2, 2012
    Posts:
    111
    Hey, I would like to know if there is a camera shake component on projectile impacts and explosions. I didnt see anything of the sort in the documentation. Thanks
     
  20. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    318
    Easy peasy actually. Let me pull up my way right fast:
    Most of thats already built into the camera script , you just need to tell it what to do.

    On what ever your using add:
    Using CoverShooter;

    then add these variables to your script:
    [Tooltip("Camera shake duration when exploded.")]
    public float ShakeDuration = 0.5f;
    [Tooltip("Camera shake intensity when close to the camera.")]
    public float ShakeIntensity = 100;

    And in your collision method:
    ThirdPersonCamera.Shake(transform.position, ShakeIntensity, ShakeDuration);

    Here is how I call my shake with explosions:
    Code (CSharp):
    1. void ExplosionWork(Vector3 explosionPoint)
    2.         {
    3.          
    4.             hitColliders = Physics.OverlapSphere(explosionPoint, blastRadius, explosionLayers);
    5.              
    6.                 foreach (Collider hitCol in hitColliders)
    7.                 {
    8.                     if (hitCol.GetComponent<Rigidbody>()!= null)
    9.                     {
    10.                         hitCol.GetComponent<Rigidbody>().isKinematic = false;
    11.                         hitCol.GetComponent<Rigidbody>().AddExplosionForce(explosionPower,explosionPoint,blastRadius,UpwardForce,ForceMode.Impulse);
    12.                         hitCol.GetComponent<CharacterHealth>().Deal(ExplodyDMG);
    13.                         ThirdPersonCamera.Shake(transform.position, ShakeIntensity, ShakeDuration);
    14.                     }
    15.                 }
    16.         }
    ** hint hint its the last line.
     
    Rahd likes this.
  21. Blackghost

    Blackghost

    Joined:
    Oct 2, 2012
    Posts:
    111

    Thanks a bunch!. Just to be clear, I put this script on the projectile collider or the prefab itself?
     
  22. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    318
    In my case I put it on my explosion prefab.sonyoull want it on your collider but you'll need to alter the code to meet your requirements. Mine was case specific
     
  23. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    Is there a way to set spawn points for the player? I'd like to set up checkpoints where the player would respawn if killed rather than starting from the very beginning .

    -rich
     
  24. myselfshj

    myselfshj

    Joined:
    Mar 30, 2012
    Posts:
    31
    Hello everyone, I've purchased this asset.
    I am reading and learning the scripts. IK part is difficult to understand.
    I'm confused about aimintensity using in IK.UpdateAim().
    Can anyone tell me what aimintensity or handintensity means? What's the purpose of using these 'intensity' ?
     
  25. Pollawat

    Pollawat

    Joined:
    Aug 27, 2016
    Posts:
    192
    Hello sir.

    How can I adjust the crosshair while character moving?



    As you can see in the video the crosshair scale up too much. Where can I adjust it?
     
  26. StaticWave

    StaticWave

    Joined:
    Aug 21, 2016
    Posts:
    17
    Finished up Weapon Scriptables, AI Scriptables and Weapon Inventory Scriptables, all with respective prefab generators.

    Next steps will be to clean up, comment and add better error handling. W4UagLvOEK.png

    Cheers
     
    Last edited: Dec 11, 2018
    JuanFLZ, satchell and Paul-Swanson like this.
  27. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Look at the posting above with the weapon setup that @StaticWave is putting together. On the far right is the Custom Crosshair settings. Here you just adjust "High Angle", "Scale" etc. not sure which just play around.
     
  28. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    Hello!

    Is there any way to modify the cover script so that if the play approaches a wall (low or high), he will automatically climb/vault the wall without going into a cover pose first? I will have some levels with no enemies so I don't need the player to take cover.

    Thanks,
    rich
     
  29. StaticWave

    StaticWave

    Joined:
    Aug 21, 2016
    Posts:
    17
    EduardasFunka,before i release the rest of the tool i need to ask if its ok. I have created scritpable objects based on some of the core scripts. I copied and pasted just the public variables from some of the core classes. I did this so the variables matched and caused as little confused as possible. The tools code does not expo any functionality just variable names. As soon as i can get a go ahead ill push out the finished tool to git and make a tutorial.

    Cheers!
     
    Neviah and SteveB like this.
  30. satchell

    satchell

    Joined:
    Jul 2, 2014
    Posts:
    107
    Maybe you can use this project to add the jump for the low covers.
    https://assetstore.unity.com/packages/templates/tutorials/mecanim-gdc2013-sample-project-9896
     
  31. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    Btw that looks awesome!
    did you do the artwork yourself?

    -rich
     
    Pollawat likes this.
  32. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Yes do it.
     
  33. StaticWave

    StaticWave

    Joined:
    Aug 21, 2016
    Posts:
    17
    OK here it is!!
    https://github.com/kristiandelay/Third-Person-Cover-Shooter-Template-Character-Tool

    I've converted all the default values to use scriptable objects, this allowed me to get around the need to create the resources folder and move folders around in the base CoverShooter project.

    I have already set up basic default scriptable objects to help get started using the tool right away. Give the scriptables folder a look and create or configure your own scriptable objects.

    Here are the new generator windows


    And here are the new scriptable object options



    The quick general use steps are to use the character generator to set up the basic locamotion controls.
    Once the character is set up, use the weapon prefab generator to create all your new weapon prefabs.
    After you save your newly created weapon prefabs you can use the weapon inventory to attach the new prefabs to the characters left and right hands.
    At this point you still need to position the weapon models. I know, I know... why can't the weapons be magically positioned for you?!

    After you have configured the weapon inventory scriptable object you can now use the AI generator on the newly created character prefab, the generator will disable the input and let the AI take over the character. =)

    That is the quick and dirty, written and video tutorials to come!

    if you have questions before i get to the readme and tutorial video ask away.

    Cheers!
     
    Last edited: Dec 12, 2018
    Lay84, uni7y, FusionSticc and 7 others like this.
  34. satchell

    satchell

    Joined:
    Jul 2, 2014
    Posts:
    107
    Appreciate the work, will definitely save time. Thanks!
     
  35. camsha

    camsha

    Joined:
    Nov 18, 2013
    Posts:
    11
    Impressive! Thank you.
     
    StaticWave and SteveB like this.
  36. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    Amazing stuff. Maybe we need to release community patch with stuff you guys sharing. Not sure if it not against asset store rules. You could push to GitHub your stuff and I will push it to store.
     
    uni7y, StaticWave and satchell like this.
  37. Dawar

    Dawar

    Joined:
    Dec 7, 2014
    Posts:
    123
    look your weapon script and also look you camera
     
  38. StaticWave

    StaticWave

    Joined:
    Aug 21, 2016
    Posts:
    17
    You can use the code that is in the github link above EduardsFunka. Im not sure what github project you want me to push it too. If you post a link i can open a pull request or something.

    Cheers
     
  39. Pollawat

    Pollawat

    Joined:
    Aug 27, 2016
    Posts:
    192
    Thank you, sir, and yes. for all of the environment parts.
     
  40. Pollawat

    Pollawat

    Joined:
    Aug 27, 2016
    Posts:
    192
    Thank you, sir, the problem is not that part sir.

    When I modifying the low, high, or scaling it also affect the shooting crosshair too. I just simply need to scale down just while moving not shooting.

    - TPS
    - Gun
    - BaseGun
    - other scripts

    I get in and hit "Ctrl+F" and search for them but I can't find it. I think I'm looking in the wrong place somehow.
     
    Last edited: Dec 13, 2018
    StaticWave likes this.
  41. uni7y

    uni7y

    Joined:
    Jul 23, 2012
    Posts:
    287
    StaticWave likes this.
  42. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    318
    Can I ask why you have 2 scripts to control mouse lock?
    ExitToEscape.cs and the MouseLock.cs script
    The one on the player and the one on the camera...
    I just merged them both with zero issue. so it doesn't seem to impede functionality.
    I noticed when i was trying to disable the mouselock and it kept getting reset in a Update.
     
    Last edited: Dec 14, 2018
  43. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    @EduardasFunka
     
  44. StaticWave

    StaticWave

    Joined:
    Aug 21, 2016
    Posts:
    17
    If you look all it does is call Application.Quit(); when the user pressed escape. I think the intent here is to not use the escape to exit script in production, it seemed to me that it was just for exiting the demo when you run the build outside of the editor.
     
  45. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    You know what would be great! Is a collider/cover setup. I have only been able to do it twice by sheer luck. Funny how on a Cover Shooter platform it's so difficult to set cover. Anyway, a menu to setup Cover would really kill!
     
    Blackghost likes this.
  46. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Just moved to 2018.3 . The root motion is now required but since when jumping my character stays in the air and landing very slowly. Any fix or tweak for that ? thanks !!!
     
  47. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    and there's a bug on the [Physics.PhysX] RigidBody::setRigidBodyFlag: kinematic bodies
    https://issuetracker.unity3d.com/is...re-not-supported-error-thrown-during-playmode
    Fixed on 2019 Beta
    i would strongly recommend 2017.4
     
    f1chris likes this.
  48. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    318
    Man this took a lot of work.
    Iv got a Menu working, Thermal \ Night Vision
    Drone Controls....
    Lordy...This template just gets better and better as you build on it.
     
  49. DankP3

    DankP3

    Joined:
    Jul 17, 2017
    Posts:
    93
    I was trying to mix the TPCS character with PuppetMaster (https://assetstore.unity.com/packages/tools/physics/puppetmaster-48977). Adding PuppetMaster seems like it should work and initial tests were encouraging, but some movement is messed up, eg. side strafing off A and D no longer works...... and perhaps more.
    Puppetmaster generates a new root object for the ragdoll when it starts and I am wondering if this is the issue with the movement? does having the TPCS character as a child object mess up movement? and if so, is it an easy fix?
    Thanks.
     
  50. DankP3

    DankP3

    Joined:
    Jul 17, 2017
    Posts:
    93
    @EduardasFunka ,

    So more insights into how controls are muddled with puppetmaster (note same results with cowboy prefab) - i have for example lost strafing when in high cover or not in cover, but in low cover strafing is fine - does this help tell what is wrong? in this video, puppet is active for the first 30s then switched off: https://drive.google.com/open?id=1CtoQJyNvRudssmutJXcBtURZws-AqAnr

    Additionally, if standing free, by rotating the camera quickly i can get momentary strafing with A and D suggesting perhaps that when the effect of the rotation is finished, the input is being suppressed?

    Any ideas please how to resolve this?