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 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:
    5,122
    Just put $10 to get things started off. I'm also attaching the promo video to this thread:

     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    That's the goal of the Deathmatch Kit. Even though it's a multiplayer setting, the goal will be for the behavior trees to be reusable so it makes sense in a single player game as well. Once we get version 1.1.1 of the Third Person Controller out the door we should have more time to work on the Deathmatch Kit. This will also benefit the Third Person Controller because there have been some feature requests for the Third Person Controller that the Deathmatch Kit will require
     
  3. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    Awesome, Justin. Thank you so much for helping out. Especially since you've already been a huge blessing to the project with your controller and tireless technical support.
     
    opsive likes this.
  4. Bones.303

    Bones.303

    Joined:
    Sep 4, 2015
    Posts:
    6
    Thanks Opsive and redchurch.
     
  5. redchurch

    redchurch

    Joined:
    Jun 24, 2012
    Posts:
    63
    Looking at the Paragon AI BaseScript.cs I'm thinking it's not quite that simple.

    Paragon had this to say;

    It turns out that setting up damage is a bit more complicated than just calling a damage method between them. I will play around some more when I get some time.

    Looks like he's got UFPS support, so maybe you guys can work it out and meet somewhere in the middle?
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    How does Paragon AI move its characters? Instead of having it move the character, you want to have the Third Person Controller move the character. Since I don't have Paragon AI I can't look at that file, but you'll need to modify the location that it actually moves the character at.

    When the character hits an object you can optionally specify an event to send. What you could do is to have another component subscribe to this event and then translate the parameters into values that Paragon can understand. Somebody else recently asked a similar question here - this thread contains some code examples as well.

    hitscan.PNG

    Sure, though right now my highest integration priority is Inventory Pro. If the Paragon AI dev wants to get started on it before I do I can help with any Third Person Controller questions.
     
    redchurch likes this.
  7. redchurch

    redchurch

    Joined:
    Jun 24, 2012
    Posts:
    63
    Oh thanks, yes, this is more what I was looking for and why I asked for integration... I don't really want to go changing all the variables and methods between Paragon AI and TPC, I'm just going to make a mess, especially since I don't know the code as well as you guys do and no doubt I would break something. A non-disruptive way like the Hitscan Damage Event or your Bridge component you did for Final IK was what I was thinking would be useful here. Ways into and out, between other products is greatness.

    Thanks for the heads up on that.

    Oh and cool, I own that product as well and have toyed with the idea of trying it in TPC. Not a priority for me personally but I will benefit from that integration as well. Happy customer here... Which reminds me, I need to submit a review. :)
     
    Last edited: Nov 6, 2015
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yeah, the damage event sounds like the way to go. This way you'll only have to add a new component, and not have to change the source from either asset.

    Awesome - I appreciate it :)
     
  9. Acid147

    Acid147

    Joined:
    Jan 1, 2015
    Posts:
    6
    I just downloaded the Third Person Controller and opened the Third Person Shooter example scene. When I start the game, move left to the barrier and press F, the character is stuck in a loop where he's walking against the barrier. The weapon disappears and I can't control the character anymore.
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for letting me know! That's a bug in the current version. It deals with having an item equipped and trying to vault. Take a look at this post for the fix. We'll be releasing version 1.1.1 within a couple of days and it'll be fixed in that version if you don't want to make the change.
     
    Acid147 likes this.
  11. Acid147

    Acid147

    Joined:
    Jan 1, 2015
    Posts:
    6
    Thanks for the answer!

    I tested a bit more and these are the things I noticed:
    • When I take cover, the character moves really slowly towards the object
    • It is possible to aim while in cover, but it isn't possible to shoot
    • I am unable to jump when standing directly in front of an object
     
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    For the first one, do you mean when the character is strafing they move slowly? I have the second one fixed, and was able to reproduce the third one. Thanks! I'll have that fixed for 1.1.1.
     
  13. Acid147

    Acid147

    Joined:
    Jan 1, 2015
    Posts:
    6
    The first one happens in the time between pressing the button and reaching the object that is used for cover.
     
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Ah, I see now. You can adjust the speed that the character moves into position by adjusting the MinMoveToTargetSpeed value on the cover ability. This is a normalized value so it ranges from 0-1.

    cover.PNG

    I have also made some improvements in 1.1.1 so the character moves into position much smoother than he currently does.
     
    Acid147 likes this.
  15. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,255
    Hi Justin, I've just purchased this package, excellent work. I plan on replacing my UFPS controller with this to add a third person mode.

    I know you've been asked before and said you'd think about adding it later but could you support a first person mode so the player can switch between the two? I made a quick switch that modifies the camera position to the characters head and this is what I got:



    It works OK, but for some reason the character disappears when the camera is close to the head position and obviously I'd like to see the body in first person mode. Also I sense the camera will not follow the head when changing height although I've not tested this yet.

    First person mode doesn't need to be complex, just have the camera follow the head/eyes and change camera fov which the user can set, this way all the existing systems would work fine. I'd be happy to hire you for a few hours if you'd be open to working on it privately? Please let me know. Thanks
     
  16. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Hi derkoi
    I've noticed that the camera zoom feature makes the character dissapear when the camera moves in your character. Try to tweak the camera zoom position in your camera component.
    I think also that a first person view is quite different that a camera position. If you are familiar to ufps you should know that the arms and weapon you see in first person view are not your character arms and they works different.
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Under Physics Options > Disable Renderer Distance you can prevent the character from completely disappearing by setting a value of 0. Which Transform is your camera anchored to? If it is set to the head then it'll track wherever the head goes.

    As @redjon29 mentioned to get the true FPS view it's more than just setting the camera position. Normally there are two cameras - one to render the hands/items and the other to render the rest of the world. This prevents the hands from clipping with objects in front of you. Your animations need to account for this to keep everything in view. This has been a popular request though so once we get further on the third person features I'd like to add it.

    In the meantime you should be able to get most of the way there. When you want to be in first person mode you can set the camera's anchor to the character's head and set the offset to (0, 0, x), where x is a value slightly in front of the character's head to prevent the head geometry from clipping. You'll also need to make sure you set the Disable Renderer Distance to 0 to prevent the character from disappearing.
     
  18. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    @opsive could you add the option to control when something is respawn instead of just a timer?
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Instead of a timer what option would you like to see?
     
  20. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Maybe a method to call when you are ready to repawn a certain game object.
     
  21. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    If you set the respawn time to -1 it will not use the timer, from there you can call Respawner.Spawn based on your own event. The only thing that you'll need to change is to make this method public instead of protected - I'll make that change on my end as well.

    Edit: Instead of making the method public, I am instead going to have it subscribe to an event. That way you don't need to even get the Respawner component reference.

    Code (csharp):
    1.  
    2.   protected virtual void Awake()
    3.   {
    4. ...
    5.   EventHandler.RegisterEvent(m_GameObject, "Spawn", Spawn);
    6.   }
    7.  
     
    Last edited: Nov 9, 2015
    kurotatsu and Gametyme like this.
  22. jbooker410

    jbooker410

    Joined:
    Mar 9, 2014
    Posts:
    41
    Hey I've noticed in this thread that many of you have replaced your animations with Kubold. What is the easiest way to handle the jumping animations? Ive tired to take Kubolds jump animations and break them down into the correct phases but when I create a new animation and trim it down to say the start of the jump It does not update under the animatio
     
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    When you replace the jump animations make sure you also add the OnAnimatorStartJump animation event. This event tells the jump ability when to actually apply the forces to jump.

    AnimationEvent.png
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Version 1.1.1 of the Third Person Controller has been sent to opsive.com purchases and should be released on the Asset Store soon. This is a bugfix/polish release and you can see the release notes within this post. The most noticeable change is a new clean scene which has all of the different movement types. We've removed all of the other prototype demos so now we just have four scenes: Clean, Shooter, Adventure, and Network.

    1.1.1.png
     
    TonyLi likes this.
  25. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    I'm a little confused about the Source Code. I'm using Unity 5.2.2f1.

    I purchased the Asset and imported the project in a new project.
    - go to website with downloadable Source Code and type in invoice number
    - download ThirdPersonControllerSource.unitypackage
    - delete /Third Person Controller/Scripts from project
    - import ThirdPersonControllerSource.unitypackage and the importer says "Nothing to Import! All assets from this package are already in your project"

    There are no other options as far as I can tell.

    I'm probably missing something simple.

    Thanks
    Allan
     
  26. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    @chaneya - we're in a limbo period right now where the Asset Store version is 1.1 but the source version is 1.1.1. Depending on when you downloaded the source versus when I uploaded a new version you could have version 1.1 or 1.1.1. I would delete the source package that you have and then as soon as you update to version 1.1.1 from the store you can then download it again. The 1.1.1 package status says "Importing" so it shouldn't be too much longer before it's live. This does bring up a good point though in that I should have two versions of the source code available: the previous version and the current version. If you'd rather get version 1.1 of the source now I can send it to you - just send me a PM or email with your invoice.

    Edit: 1.1.1 is now live :)
     
    Last edited: Nov 11, 2015
  27. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    That did it. Thanks :)

    Allan
     
  28. witchscroll

    witchscroll

    Joined:
    Jan 17, 2015
    Posts:
    131
    Hi opsive
    1
    I saw your 2.5D demo, but i do not like the upper-body swing base on the move of mouse. I know you use this effect to show player look at upper and down, but i do not need it. I want the upperbody/head do not move all the time.
    do your gui have a toggle on/off about that?
    2
    look forward to see your 1.2 with combat and enemy npc. will it support ICE?
     
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yes - you can prevent this from happening by decreasing upper body IK weight on the CharacterIK component.

    All of the combat and enemy NPC has been implemented with the Behavior Designer integration. You can see it in action on this page. In terms of ICE integration, you're wanting to be able to attack ICE creatures, correct? Versus having ICE take control of the character?
     
  30. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    In the next update could you please make the right half of the screen a touch pad that controls the camera and leave the joy stick as is on the left?
     
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I can update the clean scene to do use a combo. Is this just for an example of using the touchpad? If so you can take a look at the Adventure scene - it still uses the touchpads so you can just grab the right one from there.
     
    Gametyme likes this.
  32. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    I don't mind getting it from there but then I would have to do it every time I update. The setup with the joystick for movement and touch pad for camera is pretty much the standard for mobile 3rd person games.
     
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Are you using one of the demo scenes for your game? I'd recommend that you create a new scene that way your scene won't be affected by updates.
     
    Gametyme likes this.
  34. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    I think I startes with a demo scene and renamed it when I saved it.
     
  35. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Ah, in that case I would delete the meta file so a new GUID gets generated. This way your scene will be unique and will not be affected by Third Person Controller updates.
     
    Gametyme likes this.
  36. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    It's possible to just import the update into my existing project?
     
  37. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yes - if your scene file has a unique GUID then updating will not affect your new scene. I'd also recommend placing your own code/subclasses/items in a non-Third Person Controller folder so when you do an update you are not dependent at all on the folder structure that I submit with.
     
    Gametyme likes this.
  38. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Thats great news! Sorry for the noob question but do I delete the old third person files first or just import on top? Thanks in advance!
     
  39. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Unity packages do not handle file removals very well so if you want to be sure you don't have any of the old stuff you should first delete the Third Person Controller directory. Just make sure you aren't storing any of your own files within that directory before you do the update.
     
    Gametyme likes this.
  40. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Thanks, I have all my files separate. I haven't updated since 3 updates ago so I can't wait. Will make a backup and update tonight. Thanks for the info!
     
    opsive likes this.
  41. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    I love your stuff but we are having an issue making our own abilities. I see that you are making a video but wonder I wonder if you could simply write a tutorial. Unfortunately, we are sort of stuck until we get the information we need.

    Any chance we could get this information soon? When we purchased it a video was promised. After we purchased it one was promised. I hate making videos myself so I get it, but the ability to add our own animation groups for our own skills/abilities was the reason we bought this in the first place. :)
     
  42. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yeah, I'm running behind on that video. It's always tough because videos take a lot of time to do properly so I want to make sure the content will be relevant for the foreseeable future. With version 1.1.1 released everything should be in good shape, so right now we are putting the content together. The video will describe adding a small climb animation (such as on top of boxes or a short ledge). This ability will also go into 1.1.2.

    What sort of abilities are you looking to add? I can definitely get a written tutorial out sooner.
     
  43. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    Right now, we want to add abilities related to skills. For example, we want to add the animations for a player to chop down a tree. We have a transition from idle to chopping, then a loop for chopping. So we want to know how to add that to the controller have it triggered by a button.

    Essentially, we need to add a bunch of these...foraging for stuff, using tools such as rake or a scythe to gather, more attack animation groups, etc. I figure if we can do one, we can figure out how to do the rest. :)

    Thanks.
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    This actually sounds like a really easy ability to add - you won't need much custom logic. The first step is to derive your new ability from the Ability class. From there you can choose which methods to override. In your Chop ability the main method that you need to override is the GetDestinationState. This method is called when the ability is activated and it specifies which state should play within the Animator Controller.

    Code (csharp):
    1.  
    2. public class Chop : Ability
    3. {
    4.  
    5.   /// <summary>
    6.   /// Returns the destination state for the given layer.
    7.   /// </summary>
    8.   /// <param name="layer">The Animator layer index.</param>
    9.   /// <returns>The state that the Animator should be in for the given layer. An empty string indicates no change.</returns>
    10.   public override string GetDestinationState(int layer)
    11.   {
    12.     if (m_AnimatorMonitor.GetLowerBodyLayerIndex() != layer && m_AnimatorMonitor.GetUpperBodyLayerIndex() != layer)     {
    13.       return string.Empty;
    14.     }
    15.  
    16.     return "Chop.Chop";
    17.   }
    18. }
    19.  
    We only want to run the chop animation within the lower and upper body Animator layers so we first check the layer and then return an empty string if it's anything other than the desired layers. I used a value of "Chop.Chop" versus just "Chop" so it will look for the "Chop" state within the "Chop" substate:

    chop.PNG

    This is all that you'll need in order to get the ability running. You don't need to make any explicit transitions to this state. You can take a look at this video on how I started the Jump ability with a button press.

    From there it is just stopping the ability. In the case of your Chop ability you'll want to stop the ability as soon as the tree is cut down. For this I would use the event handler to notify the ability to stop. When your game logic has determined that the tree has been chopped down you can send the "OnTreeChopped" event to the character to stop the ability:

    Code (csharp):
    1.  
    2. EventHandler.ExecuteEvent(m_Character, "OnTreeChopped");
    3.  
    In order for this to work you ability needs to subscribe to the "OnTreeChopped" event. This would make your full ability look something like:

    Code (csharp):
    1.  
    2. using Opsive.ThirdPersonController;
    3. using Opsive.ThirdPersonController.Abilities;
    4.  
    5. public class Chop : Ability
    6. {
    7.   /// <summary>
    8.   /// Register for the OnTreeChopped event.
    9.   /// </summary>
    10.   protected override void Start()
    11.   {
    12.     base.Start();
    13.  
    14.     EventHandler.RegisterEvent(gameObject, "OnTreeChopped", TreeChopped);
    15.   }
    16.  
    17.   /// <summary>
    18.   /// Returns the destination state for the given layer.
    19.   /// </summary>
    20.   /// <param name="layer">The Animator layer index.</param>
    21.   /// <returns>The state that the Animator should be in for the given layer. An empty string indicates no change.</returns>
    22.   public override string GetDestinationState(int layer)
    23.   {
    24.     if (m_AnimatorMonitor.GetLowerBodyLayerIndex() != layer && m_AnimatorMonitor.GetUpperBodyLayerIndex() != layer) {
    25.       return string.Empty;
    26.     }
    27.  
    28.     return "Chop.Chop";
    29.   }
    30.  
    31.   /// <summary>
    32.   /// The tree has been chopped. Stop the ability.
    33.   /// </summary>
    34.   private void TreeChopped()
    35.   {
    36.     StopAbility();
    37.   }
    38. }
    39.  
    With this code you can start your ability, play an animation, and stop that ability. There are more Ability methods that you can override but most of those deal with movement. Since your chopping animation is probably going to be standing still you don't need to worry about most of them. The one method that you probably want to override is the CanUseIK method to return false on the upper layer - in this case you don't want IK interfering with your animation.
     
    Last edited: Nov 16, 2015
  45. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    Thank you! :) Hopefully that will do it.
     
    opsive likes this.
  46. drakekaz

    drakekaz

    Joined:
    Jan 16, 2014
    Posts:
    43
    Hello again, loving the updates so far, just having an issue with the new footstep script and it seems that the documentation on your site is for the older events system. Is there any updated information on how this new footstep system works?
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for letting me know - I just updated that documentation page:

    http://opsive.com/assets/ThirdPersonController/documentation.php?id=15

    Previous versions used animation events, but duplicate animation events could fire within the blend tree so this doesn't work too well for determining when the foot is on the ground. In version 1.1 we switched to triggers and that has worked a lot better.
     
  48. TonanBora

    TonanBora

    Joined:
    Feb 4, 2013
    Posts:
    493
    How would I trigger an Ability via GUI Input?
    Would I need to use Events?
    If so, how would I need to set them up within the Abilities' script?
     
    Last edited: Nov 24, 2015
  49. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Within the Input Start Type you'd set the type to Manual, and then start the ability with:
    Code (csharp):
    1.  
    2. RigidbodyCharacterController.TryStartAbility(typeof(AbilityType));
    For example, if I wanted to start the Jump ability I would do:
    Code (csharp):
    1.  
    2. m_Controller.TryStartAbility(typeof(Jump));
     
  50. TonanBora

    TonanBora

    Joined:
    Feb 4, 2013
    Posts:
    493
    I get an error when I attempt the TryStartAbility that states:
    Cannot convert from "System.type" to "Opsive.ThirdPersonController.Abilities.Ability"
     
    Last edited: Nov 24, 2015
Thread Status:
Not open for further replies.