Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Third Person Controller - Third Person, AI, Multiplayer, Mobile Framework

Discussion in 'Assets and Asset Store' started by opsive, Jan 21, 2015.

Thread Status:
Not open for further replies.
  1. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    Take a look at the Movement blend tree for the clean scene. You'll see that the running animations play when the horizontal and forward input parameters are 1. To get your character to walk by default you'll want to replace these animations with the walking animations. The SpeedChange ability should then have a Speed Change Multiplier of 2 so the horizontal and forward input parameters have a value of 2 when running. You can compare your blend tree/ability to the shooter scene as this is the default setup.

    Also, not directly related, but if you haven't done so already I highly recommend duplicating the clean scene animator controller and assigning that to your character. This will prevent that animator controller from being updated whenever a new third person version comes out.
     
  2. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Thanks! I figured that was the case. Was hoping it was a simple bool somewhere though. I have a lot of movement sets.

    Yeah, I duplicated it. Forgot to do that last time and am kicking myself. Made it better this time anyway.
     
  3. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I've written my own script that sets various things on weapons such as sprite, fire sound, damage, and clip size. Everything works except for the clip size. The gun needs to be reloaded before the clip size resets to the size of my script. What's the best way to get the gun to use the clip size on my script? I'm trying to keep the edits of your scripts down to simply making things public. I'm basically trying to have several different handguns the player can use that all use the same weapon slot. I've got everything working but that one little thing.
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    How did you modify the fire sound or damage? By making the variables public? Can't you use a similar method as the clip size field?
     
  5. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    That's what I did but the clip size doesn't register until I reload the weapon. So, when the shooter script clip size is 15 and my script is 6, it starts off at 15 but when I reload, it goes down to 6.
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    It's tough to say without seeing what you are actually doing, but could you override either StartReload or ReloadComplete? This will then allow you to use the clip size in any way.
     
  7. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    All I did was set the variable to public and write a simple script that finds the shooter script and changes them:
    Code (CSharp):
    1. void Update () {
    2.         if (myShooter == null)
    3.         {
    4.             myShooter = GetComponentInParent<ShootableWeapon>();
    5.             if (myShooter != null)
    6.             {
    7.                 myShooter.m_FireSound[0] = m_FireSound;
    8.                 myShooter.m_ClipSize = clipSize;
    9.                 //myShooter.m_Inventory.ReloadItem(myShooter.m_ItemType, clipSize);
    10.                 myShooter.m_HitscanDamageAmount = damage;
    11.                 myShooter.m_ItemSprite = mySprite;
    12.             }
    13.             return;
    14.         }
    15.     }
    It changes everything but the clip size doesn't take effect until after a reload. I'll try to override those and see what happens.
     
  8. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Yeah, just calling ReloadComplete fixes the issue.
     
  9. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Thanks it is working
     
  10. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    opsive likes this.
  11. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    Definitely seeing progress :)

    Thanks for sharing your tree! I've been working on the Deathmatch Kit tree and we are getting closer and closer to being able to create a WIP thread with a playable demo. You'll be able to get some more ideas for your AI from that tree as well.
     
  12. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    So cool i'm still study the soldier behavior tree provided with the sample scene, new examples will be great I'm just beginning to have working npc
     
  13. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    191
    I wanted to ask, would your controller support something like boost climb with two characters. 1 character boosts up the other character to climb.
     
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    You'd have to create a new ability for that but yes, it would be able to support it. You could start with the Short Climb ability for the character being boosted and then create a new ability for the one doing the boosting. These abilities would have to coordinate with each other so the animations match but besides that it would be setup like a normal ability.
     
  15. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    191
    Would I need to do any programming? I would need to blend the boost animation with the climb animation somehow.
     
  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    Yes, this would involve programming. There's a guide on this page and a video on this page. I like the idea though of creating an ability that works in conjunction with another ability on a different character though - I've written it down :)
     
  17. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    191
    Aww man, programming is something I'm not even close to being good at... I'm thinking of how I'm going to get this to work with minimal programming.

    If the boosting character can carry the climb character on their back then I can maybe blend the short climb into it. Just like elevating the character to be able to grab the ledge.

    EDIT: Is there a way to see the raycast rays.
     
    Last edited: Feb 5, 2016
  18. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Hello, I thought about a suggestion for an update. Is it possible to turn on the ragdoll when the character falls from too high or is hit with a weapon with more than a minimal force. Ex explosion
    For the item system I would like my character can have only 3weapons equipped one rifle, one handgun and one melee. The holster system is very good for that but if I have much weapons my character will look like a hedgedog.
    A new ability for the character wich can move with a different animation when his life is low like in the old resident evil would be great too.

    Ps. New video of my project will be released soon with a cutscene mase with BD.
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    This sounds like a perfect situation for the PuppetMaster integration.
    The items currently do not have any categories but I know that the Inventory Pro integration does have this feature. I have written the suggestion down though for the Third Person Controller.
    Noted :)
     
    redjon29 likes this.
  20. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Thank you I'll check for Puppetmaster ;)
     
  21. Deckard_89

    Deckard_89

    Joined:
    Feb 4, 2016
    Posts:
    284
    I was thinking the same thing for the Resi style injured animations. Maybe there's some way for Mecanim parameters to communicate with the TPC health variable, to trigger the limping movement or whatever.
     
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    You could override CanStartAbity and have it check the health. If the health is under a certain threshold then the ability would start. The Start Type would be set to Automatic. It should be relatively easy to add this ability, we'll try to get it in some rather than later.
     
  23. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I haven't done this specifically, but I did set up multiple animations for the same weapon by simply making public the "Item Name" and the other animation "name" variables in the shootable weapon script and making a little script that changed them. Made it so I can switch between full-auto and semi- with the same weapon. While I was only changing one animation, the basic principle's the same.
     
  24. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Hey, if anyone wants here's a code snippet I added to the raycast of shootableweapon.cs around line 615. It basically "normalizes" the raycast hit height based on the center and bounds and then adds a damage multiplier thus a very simple way of adding a head shot.

    Code (CSharp):
    1. float damX = 1;
    2.                 float temp1 = m_RaycastHit.point.y - m_RaycastHit.collider.bounds.center.y;
    3.                 float temp2 = temp1 / m_RaycastHit.collider.bounds.extents.y;
    4.                 if (temp2 > .75f) damX = 10;
    5.                 else if (temp2 > 0.25f) damX = 3;
    6.                 else if (temp2 > 0f) damX = 2;
    7.                 else damX = 1;
    Then change the damage messages to m_HitscanDamageAmount * damX instead of just m_HitscanDamageAmount.

    I suspect there's a better way of doing it, but this is what I came up with.
     
    Last edited: Feb 6, 2016
    redjon29 and opsive like this.
  25. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Excuse me i just know nothing about scripting but do you just copy paste your script line 615 and it works? Can you set the damage multiplier in the inspector?
     
  26. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    It needs to go in the brackets of the raycast. Look for
    Code (CSharp):
    1.  if (Physics.Raycast(m_FirePoint.position, fireDirection, out m_RaycastHit, m_FireRange, m_HitscanImpactLayers.value))
    2.   {
    AROUND line 615. I edited the code so it might not be exactly that line, but look for that line of code and paste it in right after the first bracket. It's not currently set up so you can set the damX in the inspector. If you want to change it, probably easiest just to change the number after damX= to whatever you want. I didn't see any benefit to exposing it in the inspector since I wanted three different values that an easy formula really couldn't get. Couldn't think of an easy way to come up with 1,2,3, & 10 other than just hard coding it.
     
  27. mobgato

    mobgato

    Joined:
    Nov 20, 2015
    Posts:
    19
    Hello !

    Looks cool. I wanna create a Multiplayer TPS Shooter Game.
    Can I create with just Third person Controller asset or should buy addons too ?

    and Does this support GooglePlay Real-Time Multiplayer? or This can be added?

    Thanks
     
  28. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Thanks I'll trt it soon
     
  29. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92

    Another video of my project at the end i put a lot of ai.
    I would like to see other videos of projects if someone could share
     
    opsive likes this.
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    If all that you want is multiplayer you shouldn't need anything else - UNET support is built into the asset. UNET does support Android but I am not sure of the underlying technology that it uses in order to allow it to work.
     
  31. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,835
    Justin, what setting should I adjust so that my character doesn't skip hop down slopes? I seem to recall there being a setting I could adjust that had something to do with minimum fall height, but I can't seem to find it.

    EDIT: I found it. Sorry for post.
     
  32. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846

    I've just uploaded the InControl integration to the Integrations page. No core Third Person Controller changes are required so the integration files are all that you need. Make sure you also take a look at the documentation as this integration takes some extra setup compared to the other input integrations.
     
  33. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    In some cases when I am holding down the sprint key, stamina goes down even if I am not moving any longer. For instance, I am using the ORK integration and if ORK takes control for an event or menu while sprinting, the stamina goes down but the player stops moving. I changed it so it checks the Animator state to make sure it is in Movement before reducing the stamina. Would it be better to check the Horizontal and Forward Input instead? Or even some other way to make sure the player is actually moving?

    Thanks!
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    We could tie it to the character's moving state:
    Code (csharp):
    1.  
    2.   // The stamina should only decrease if the character is moving.
    3.   if (m_UseStamina && m_Controller.Moving) {
    4.  
     
    drewradley likes this.
  35. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Didn't even know that was an option. That's perfect! Thanks!
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    I thought that this was awesome so I had to share - @RoyalAllen adjusted the camera so the Third Person Controller appears in a first person view. It works surprisingly well - looks like we don't need to do UFPS 2 now ;)

     
  37. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,835
    What's the roadmap and timeline now for the next version of TPC?
     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    We'll be releasing a small update in a few days which is just a polish release with a few bug fixes and minor set of features. This will be version 1.2.2. The next update will then be 1.3 and it will contain the big item system update.
     
  39. RoyalAllen

    RoyalAllen

    Joined:
    Oct 17, 2012
    Posts:
    140
    Thank you for sharing! It moves well this way. Feels natural in first person. Great asset money well invested. Integrating it with Paragon Ai now Know as Tactical Shooter Ai. It going very well be glad to share if anyone needs help. Just send me a message. :)
     
    redchurch likes this.
  40. RoyalAllen

    RoyalAllen

    Joined:
    Oct 17, 2012
    Posts:
    140
  41. Nateply

    Nateply

    Joined:
    May 20, 2014
    Posts:
    46
    Awesome! Thank you * 1,000,000. I see possibilities ... like overlaying an FPS HUD when in that mode, different camera filter, audio effects, etc. Wow!
     
  42. RoyalAllen

    RoyalAllen

    Joined:
    Oct 17, 2012
    Posts:
    140
    Your welcome! I thought of the same exact thing when I stumble upon this. Good luck with your game!
     
  43. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    I've gotten a few questions on using the Generic Ability so I've created a quick video showing how to use it:

     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    Version 1.2.2 of the Third Person Controller has been sent to opsive.com purchases and is making its way to the Asset Store. You can see the full change list here. This is a minor release but does contain some good improvements such as smoother controls/transitions. It also updates the NavMeshAgentBridge so AI agents can work with off-mesh links. One use for this is to allow your AI to jump:

    jump.gif

    You can then extend this for more interesting actions such as using an air lift:

    airlift.gif

    These videos were taken from our upcoming Deathmatch Kit asset.
     
  45. RonnyDance

    RonnyDance

    Joined:
    Aug 17, 2015
    Posts:
    557
    Are the online demos updated with the newest 1.2.2 responsiveness update so see how smooth the controller is now?
     
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    Yes, they are
     
  47. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    3,835
    Already downloaded and updated mine. Looking good so far.
     
  48. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    191
    Does this work with Simple Waypoint System? I checked your site for integration but couldnt find anything.
     
  49. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    4,846
    I have not tested it with SWS. I can look at an integration with it though
     
  50. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,075
    Good to know this can work. I have (and like) both TPC and UFPS, but my current project is using TPC. I was planning to try something like this to allow a "limited" FP view in my project, not needing the full feature set of UFPS for this.

    The position of the bow needs some adjustment, in my opinion (I shoot a recurve bow in real life), but that's a minor nit. For an experimental demo, this is pretty darned good!
     
    RoyalAllen likes this.
Thread Status:
Not open for further replies.
unityunity