Search Unity

Third person cover controller

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

  1. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    I do not own puppet master. No idea why its happening.
     
    Camelot63RU likes this.
  2. DankP3

    DankP3

    Joined:
    Jul 17, 2017
    Posts:
    93
    Could you perhaps be raycasting or equivalent to determine if movement is possible and it impacting on the ragdoll colliders - i have my ragdoll in a dedicated layer, but don't know how you determine if a player can move or not?

    Update: as you probably realised moving in low cover is forward-backward axis and not strafing - hence the difference, so I expect there is some conflict with the sideways movements at the heart of this.
     
    Last edited: Dec 18, 2018
  3. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    Hello


    Is there any reasonable way to animate the Player in the Timeline? I'm trying to make a cut scene but I can't get the Player character to play it's animation clips correctly. Any suggestions?

    thanks,
    rich
     
    Paul-Swanson likes this.
  4. DankP3

    DankP3

    Joined:
    Jul 17, 2017
    Posts:
    93
    @EduardasFunka ,
    Solved this. It was indeed a raycast (Util.IsFree), which has no layermasking and was impacting my ragdoll. I assume this would have the same issue with any attempt to ragdoll.
    Whether you want to add a mask here is a possibility, but I am good now?
     
    satchell likes this.
  5. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170
    I'm trying to create targets on object (not AI) that will then trigger an animation. So the play shoots the target and something happens. Any suggestions?

    thanks,
    rich
     
  6. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170

    I'm using simple Collider Trigger Events to register hits not the Targets. The problem is the bullets don't seem to register a hit on the target. Other objects do, but not any of the bullets...
     
  7. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    319
    It's a speed issue. I had the same. Copy the on hit method from his bullet scripts. For the obejects taking hits. Check out my destructable objects see from a few pages ago. That should help you
     
  8. Saoc118

    Saoc118

    Joined:
    Jul 11, 2018
    Posts:
    3
    I tried to use the script for the ammo pickup and have the followings errors: Type `CoverShooter.BaseGun' does not contain a definition for `BulletInventory'

    I know the error is in the referenced script, the variable "BulletInventory" is stored in "Gun.cs", i tried to making work with no luck, Can someone help me? And if is possible to make unique ammo fo each weapon? thanks in advance and sorry for my bad english :(
     
  9. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    319
    Each guns ammo count is already unique to the weapon type. I also already posted a ammo pickup script a few pages back. I'm out and about right now so I can't post it. But once I get back....unless you find it first ..I'll link to my earlier post. Just check this thread for my comments and you'll find what you want
     
    Camelot63RU likes this.
  10. Saoc118

    Saoc118

    Joined:
    Jul 11, 2018
    Posts:
    3
    I found it, thanks you very much!!
     
    Paul-Swanson likes this.
  11. claudiorodriguescampos

    claudiorodriguescampos

    Joined:
    Jun 23, 2017
    Posts:
    98
    @EduardasFunka ,

    In the Third Person Cover scene, when I start the game, the cowboy doesn't do any anything if I click the left mouse button, I need to scroll the mouse button to change the weapon. Is it possible to start the game using a specific weapon?
    Or maybe just remove the unarmed state?
     
    Last edited: Dec 19, 2018
  12. webgrapx

    webgrapx

    Joined:
    Jul 21, 2015
    Posts:
    22
    Greetings, I have a problem with version 3.0 of Unity, since the character and the AI do not move. You could help me with it.

    Thank you
     
  13. rrabassa

    rrabassa

    Joined:
    Jul 17, 2013
    Posts:
    170

    Thanks! I took your script and modified it a touch to allow another object to activate!





    Screen Shot 2018-12-19 at 3.58.49 PM.png
     
    satchell, SteveB and Paul-Swanson like this.
  14. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    rrabassa likes this.
  15. Camelot63RU

    Camelot63RU

    Joined:
    Jul 20, 2014
    Posts:
    17
    Hi, any news about update?
     
  16. EduardasFunka

    EduardasFunka

    Joined:
    Oct 23, 2012
    Posts:
    467
    We working on that little slower than expected. It is coming.

    And nice merry Christmas everyone!
     
    Camelot63RU and satchell like this.
  17. satchell

    satchell

    Joined:
    Jul 2, 2014
    Posts:
    107
    Get back to work! Kidding... Thanks, Merry Christmas!
     
    Camelot63RU likes this.
  18. gsmax

    gsmax

    Joined:
    Jun 12, 2018
    Posts:
    15
    Thanks guys for all your help through the year.
    You really don't know how much you have helped......Hope to see some video tutorials from some of you guys soon.
    Merry Christmas and a Happy New Year.
    @EduardasFunka I hope we get the update as an early New year gift.
    Thanks again.
     
    Rahd and satchell like this.
  19. Jhorvath9

    Jhorvath9

    Joined:
    Nov 22, 2015
    Posts:
    9
    Merry Christmas to everyone!
    So I've been playing around with this asset quite a bit lately and I'm enjoying it but have a few questions I'm hoping I can get some help on (did some searches here but didn't quite find what I was looking for).
    1. I'm not really much of a programmer so I'm struggling to figure out how bullets are registering a hit on a collider. The reason I ask is that I'm putting some invisible walls throughout my level so that the player and enemies don't walk into certain areas, however, I still want bullets to pass through. I messed with the physics matrix with layers and such but no matter what layers are set to the bullet or guns, they won't pass through my other colliders (even adding a collider to the bullets doesn't fix this) I have on my invisible wall layer. Does anyone have any suggestions on how to get this to work?
    2. My level is going to be a wave based shooter, so I'm going to be spawning enemies at random points on the map. I was hoping I could set the start mode to "search around" so that when the AI spawns, it would just search around the nav mesh until it ran into the player. Of course "search around" doesn't seem to do anything (even rebaking the nav map and such). Unfortunately search position and investigate just send the AI to the position I set but they go there in a straight line, not using the nav mesh. I've also made the fov all the way up so the AI finds the player right away, but if the AI view is obstructed by obstacles to the player it will sit there. Is there a way to get the AI to spawn and just start searching the nav mesh?

    Any help is appreciated! Thanks!
     
  20. satchell

    satchell

    Joined:
    Jul 2, 2014
    Posts:
    107
    Hey @CrazedArabMan Welcome!

    1. Scroll to the bottom... https://answers.unity.com/questions/416906/make-raycast-ignore-some-objects.html
    Have you tried Tag's? this link
    Code (CSharp):
    1. RaycastHit[] allHits;
    2. allHits = Physics.RaycastAll(transform.position, fwd, 10);
    3. foreach (var hit in allHits)
    4. {
    5.     // now filter by tag or name
    6.     if (!hit.transform.tag.equals("Invisible Wall")) {
    7.         // yeah, we didn't hit something tagged as "Invisible Wall"
    8.     }
    9. }
    2. Maybe spawn the AI Waypoint to patrol the common areas?

    Hope this helps!
     
    Last edited: Dec 25, 2018
  21. Jhorvath9

    Jhorvath9

    Joined:
    Nov 22, 2015
    Posts:
    9
    Awesome! Putting the walls on the "ignore raycast" layer worked wonders! I thought about tags too, but it always seemed like layers was what I wanted (though I originally had my walls on a new layer I made). Thanks again for this!

    As for the AI, my map is somewhat big which is the issue, so I really don't want them to follow a set path. I'll continue to play around with it some more to see what I can get setup with it. If anyone though has some suggestions, I'm open.

    Last "wish" per say. I like that you can vault over cover on the low cover, however it's a shame there isn't a "is vaultable" check box on each piece of cover you put on the map in the script. I have some low cover that I don't want to be vault-able (due to a cliff on the other side). I have it working but it's more of a bandaid fix by using a separate invisible wall that's just a tad higher than the cover piece, thus causing the player not to be able to vault. It works, but a checkbox like that would be really nice.
     
    satchell likes this.
  22. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    Merry Christmas everyone , it's been a while , i hope all of you are doing ok .
     
  23. Unplug

    Unplug

    Joined:
    Aug 23, 2014
    Posts:
    256
    @EduardasFunka should we download the version from unity store or github which one is the most recent. github seem outdated. im not good at all at github but it show date of last update and the folder are all old so it doesn't feel the most recent version. i try to keep updating my project with most recent one but since i do it manually its long and i wait between minor update.
     
    f1chris likes this.
  24. Saoc118

    Saoc118

    Joined:
    Jul 11, 2018
    Posts:
    3

    Hello! i try this to integrate the Emerald AI, its seems to be outdated, someone can share how to integrate or guide me on how to implement the Emerald AI please? Thanks in advance!!
     
  25. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Sam
    Same here. I a patreon to b able to follow progression and new development from github repository but now we can only see the old version (same as on assetstore) i don’t see the point continuing supporting him.
     
  26. Paul-Swanson

    Paul-Swanson

    Joined:
    Jan 22, 2014
    Posts:
    319
    I will say this from a git point of view. the folders date themselves don't always change when something is pushed. Its a stupid quirk of Unix. Just because the folder date didn't change doesn't mean that the repo itself isn't updated. Check the date on the FILES not the directories.
     
    jnbbender likes this.
  27. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    @EduardasFunka Whenever I open my Project I always receive the "OnLevelWasLoaded was found in AISearch" warning. I notice you do this on line 228. I understanding supporting Unity 5.x but should this be wrapped in an nifty #ifdef conditional so you can provide the updated implementation of SceneManager.sceneLoaded?
     
  28. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    @EduardasFunka Okay, I'll try and do my best here. I am a fan of the user having to manually reload weapons and the dry fire sounds a gun makes. When I tried to simply deselect the toggle "Auto Reload" on the gun and add the Empty Fire sound I was surprised to see that none of it worked. The last time this seemed to be brought up was on page 18 of this forum. Looking at the code, this feature was NEVER tested. So here is the beginnings of the fix to rework the functionality of shutting off Auto Reload and adding Empty Fire sounds.
    First off know that the player has the right to fire the weapon any time he/she would like to. Remembering that.

    BaseGun.cs
    line 540 remove the _isAllowed flag
    Code (CSharp):
    1. if (_isFiringOnNextUpdate) //&& _isAllowed
    2.  
    Pull the if (LoadedBulletsLeft <=0) out of the if (hasFired) block
    Code (CSharp):
    1.  
    2. if (hasFired)
    3. {
    4.     for (int i = 0; i < _listeners.Length; i++)
    5.         _listeners[i].OnFire(delay);
    6.  
    7.         if (Fired != null) Fired.Invoke();
    8.  
    9.         if (Character != null)
    10.         {
    11.             if (PumpAfterFire)
    12.                 Character.InputPump(0.1f);
    13.  
    14.             Character.InputRecoil(Recoil.Vertical, Recoil.Horizontal);
    15.             ThirdPersonCamera.Shake(Character,  Recoil.ShakeIntensity, Recoil.ShakeTime);
    16.        }
    17. }
    18.  
    19. Debug.Log("LoadedBulletsLeft " + LoadedBulletsLeft);
    20. if (LoadedBulletsLeft <= 0)
    21. {
    22.     for (int i = 0; i < _listeners.Length; i++)
    23.         _listeners[i].OnEmptyFire();
    24.  
    25.     if (EmptyFire != null) EmptyFire.Invoke();
    26. }
    27.  
    ThirdPersonController.cs
    line 550 change
    Code (CSharp):
    1. if (gun != null && gun.LoadedBulletsLeft <= 0)
    to
    Code (CSharp):
    1. if (gun != null && gun.LoadedBulletsLeft <= 0 && gun.AutoReload)
    CharacterMotor.cs
    line 5091 change
    Code (CSharp):
    1. if (gun == null || gun.LoadedBulletsLeft == 0)
    to
    Code (CSharp):
    1. if (gun == null)
    Haven't looked at what other kind of cleanup this entails but seems like a BIG bug since they are 2 apparent features of the gun that just don't work.
     
    Last edited: Dec 28, 2018
    satchell likes this.
  29. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Sorry, I can't help myself now. Want a simple optimization? In BaseGun.cs, get rid of the LateUpdate() method and add change
    Code (CSharp):
    1. public void FireWhenReady()
    2. {
    3.      _isGoingToFire = true;
    4. }
    to
    Code (CSharp):
    1. public void FireWhenReady()
    2. {
    3.     _isGoingToFire = true;
    4.     Frame();
    5. }
    No need for it since it's triggered from CharacterMotor
     
    satchell likes this.
  30. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Beep! Beep! Need help. Here's what I want:

    I have an ally that's standing next to me. He really loves me ofcourse. :p
    What I want is if I hit him or shoot at him, I want him to become my enemy. Anyone??? :(
     
  31. Rahd

    Rahd

    Joined:
    May 30, 2014
    Posts:
    324
    the biggest performance eating code is :
    -the raycasting for the ground , on the CharacterMotor it gets called a lot not sure if it's necessary
    the animator update get's called regardless of there's an animation change or not each frame
    same goes for the cover update , and weapons update ... ect
    this is crucial for mobile the updates are killing the build . please fix this .
    i have limited the use of the cover ai to a max of 4 , since it's too much above that
    please fix this :(
     
    Munken and angel_m like this.
  32. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    Did you try playing with the Actor component of your ally ? I imagine if your player is by example Actor = 0 and you Ally is 0 as well and let say all other ennemies = 1. I would simply use the Health component as a trigger. Don’t have the details in front of my but the when receiving Hit in Health component you can know if the aggressor Tag = Player . When it’s the case, switch Ally Actor to 2. That way he’ll go against you but he’ll stay an ennemy of your ennemies ;-)
     
  33. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    I'm really procrastinating getting my scenes going for my game; not looking forward to lighting challenges, etc. One thing I really hate about this asset is the time it takes to place Cover. So I thought I'd write something we could all use. This script will add the "cover" colliders, script, and Cover layer to the objects you select as cover. Add this to your Editor folder, select your objects and click "GameObject->Add Cover to Selections". It's super basic. It only adds colliders on the Z-Axis since the X-axis requires really wacky rotations. Try it out with a test scene first so you know how it works. If anyone wants to improve it, fix it, etc. just go for it.

    If you find the colliders are just too close to your walls, adjust the BUFFER_VALUE in the script.

    EDIT:
    See updated script ( @Blackghost )
    https://forum.unity.com/threads/third-person-cover-controller.472313/page-31#post-4056262
     

    Attached Files:

    Last edited: Jan 5, 2019
    Blackghost, f1chris and Paul-Swanson like this.
  34. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Hi again! Can one please help me with something?
    It's a camera causing problems.

    Here are 2 screenshots.

    WHAT I WANT
    C2.PNG


    WHAT TPCS IS DOING:
    C1.PNG

    The problem is, I want my camera from back of my character when I start playing but don't know why it just start with some weird rotation from front or in some scenes from other angles.

    AM I THE ONLY ONE FACING THIS ISSUE?
     
  35. satchell

    satchell

    Joined:
    Jul 2, 2014
    Posts:
    107
    Where's the position of your camera in the scene? Is it positioned where you want it at play?
     
  36. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    Position of camera is exactly where I want it but not it's rotation.
     
  37. satchell

    satchell

    Joined:
    Jul 2, 2014
    Posts:
    107
    on line 246 of ThirdPersonCamera.cs you can change the horizontal to 0 you find the setter for rotation now the root of the Y axis degree are confusing to me. Maybe it is updating the view direction from the Character controllers? But I can't locate in the scripts how/where it assumes a target at start if it is a target or cursor type function.
     
    Last edited: Dec 31, 2018
  38. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Yeah, this is a stinker. Mine starts at the right foot. But his Prototype Scene does as well and his Main Camera is positioned well on the other side of the playing field.

    EDIT:
    Quick optimization. While looking at this code he's got some kind of circular calling thing going on. He's triggering the CharacterMotor to call a camera update (UpdateForCharacterMotor) but then he's doing it as well. So in ThirdPersonCamera.cs get rid of LateUpdate() entirely.
     
    Last edited: Dec 31, 2018
    Blackghost, Rahd and satchell like this.
  39. manumartinez

    manumartinez

    Joined:
    Nov 17, 2014
    Posts:
    5
    Hi, has anyone tried to use this plugin on PS4? Because in PC it works perfect but when I exported to PS4, the character can't jump and walks in the air when I try to climb something and never fall. Any ideas? Thanks!

    PD: I'm using Unity 2018.2.20
     
    Last edited: Dec 31, 2018
  40. timinal

    timinal

    Joined:
    Jul 19, 2012
    Posts:
    24
    I was also struggling with this, but I finally found a way to do it!

    Make a new script and attach it to the Third Person Character/Player and put this into the Start () method:

    Code (CSharp):
    1. void Start ()
    2. {
    3.     GameObject.FindWithTag("MainCamera").GetComponent<ThirdPersonCamera>().Horizontal = transform.eulerAngles.y;
    4. }
     
    satchell likes this.
  41. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Can you give me context? I'm trying to implement umair21 script fix but I'm not sure which horizontal you are talking about.
     
  42. satchell

    satchell

    Joined:
    Jul 2, 2014
    Posts:
    107
    On line 246 of ThirdPersonCamera.cs if you replace
    var rotation = Quaternion.Euler(vertical, horizontal, 0);
    with
    var rotation = Quaternion.Euler(vertical, 0, 0);
    . This results in the Camera's Y rotation to freeze behind the player. It looks to be the optimal rotation when the game starts, though the Y rotation is frozen. Locking any mouse cursor input.

    Maybe an IEnumerator to wait a few seconds before the actual game starts to give a clean look but after the few seconds the rotation would maybe fly to the right as normal. So something like the following but I'm just a hobbyist.
    Code (CSharp):
    1.     void Start()
    2.     {
    3.         StartCoroutine(Example());
    4.     }
    5.  
    6.     IEnumerator Example()
    7.     {
    8.         print(Time.time);
    9.         yield return new WaitForSeconds(5);
    10.         print(Time.time);
    11.     }
     
    Last edited: Jan 1, 2019
  43. timinal

    timinal

    Joined:
    Jul 19, 2012
    Posts:
    24
    The code I posted doesn't work for you?
     
    satchell likes this.
  44. satchell

    satchell

    Joined:
    Jul 2, 2014
    Posts:
    107
    Hey @timinal, ws just elaborating on my post per jnnbender's request. Your code is a great solution. I guess jnnbender Is looking for the root that controls the rotation.
     
  45. timinal

    timinal

    Joined:
    Jul 19, 2012
    Posts:
    24
    Ah, I see. :)
     
  46. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    my camera starts at the foot so instead of slowly lerping to the head it quickly jumps to the head. That tells me the problem is before UpdatePosition.
     
  47. Jeomar

    Jeomar

    Joined:
    Jun 30, 2017
    Posts:
    4
    Hey everyone! Hope everyone excellent Christmas and New Years. I have a couple questions, is it possible to swap out the cowbow character and put my own in? How easy is it to set up?
     
  48. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    Sorry for the last AddCover.cs script. It was a mess. It did not take into account different meshes, positioning was messed up. I performed a few more tests with this one against trees and such. Hopefully this works out for everyone.

    EDIT:
    I don't feel like posting another script. You may get some camera shake. If you do change the "new Vector" localScale z position from 0.05f to 0.1f. Also, turn up the BUFFER_VALUE to something like 0.07f
     

    Attached Files:

    Last edited: Jan 5, 2019
    Blackghost likes this.
  49. TotalPixel

    TotalPixel

    Joined:
    May 26, 2012
    Posts:
    19
    Hi, does anyone know of a way where i can switch the mobile controls from using touch input to using xbox controller sticks instead. I want the movement from the mobile scene.

    Any help appreciated :)
     
  50. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    487
    If you go to the Asset Store you can catch all his videos. This one
    is for the Character setup. It's the most recent one I can find. He doesn't explain anything, just mumbles so copy and paste as he does and you'll pick it up later.
    This process is known to be a pain so @StaticWave wrote a great utility to auto setup a Character. Check it out on page 29 https://forum.unity.com/threads/third-person-cover-controller.472313/page-29. Look for the Pink.
     
    StaticWave likes this.