Search Unity

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. heartquinoa

    heartquinoa

    Joined:
    May 10, 2018
    Posts:
    3
    Thank you, that was it!

    Was this info anywhere on the site and I was just missing it? If not, it should probably be. It would have taken me days to figure that out myself.
     
  2. IsntCo

    IsntCo

    Joined:
    Apr 12, 2014
    Posts:
    146

    Do you know how people are currently getting the existing version working with PUN?
     
  3. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Unfortunately I don't - I generally only hear of things when they go wrong and I have heard of some people mentioning that they are working on PUN integration but I don't know how well that aspect is going.
     
  4. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    there is a small amount of downward pressure when standing on a slope. So when facing the top of the ramp and the input is strafe straight right, it moves right and down the ramp. Is there a way I can exclude the downward force on the ramp so that the character will move straight sideways?
     
  5. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    I can do one better - it will not require root motion to be deselected in the next version so you won't have to go hunting for it :)
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    This sounds related to this post, correct? Besides going the ability route which modifies the rigidbody force my only suggestion would be to see if applying a physic material helps at all.
     
  7. David5988

    David5988

    Joined:
    Sep 9, 2011
    Posts:
    141
    Is there a way to hang and then climb up like the old school Tomb Raider games?


    What are the settings to achieve this?
     
  8. Blackghost

    Blackghost

    Joined:
    Oct 2, 2012
    Posts:
    111
    Hey Opsive, I think I asked this before, not sure. Does a root bone have to be added to rig in a 3d package in order for TPC to use the enable root bone option? Does TPC automatically add one, if one isnt found in the skeletal rig?
     
  9. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Yes - on the right side of the clean scene on the second floor there is a ledge that you can hang and then climb up from. This is a combination of the hang ability along with short climb. The only trick with this one is to ensure the short climb ability is above the hang ability so it has a higher priority.
     
    Blackghost likes this.
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    I'm actually not sure how the internal root motion logic works, but I would assume that it does need a root bone. The Third Person Controller will not automatically add one.
     
  11. Blackghost

    Blackghost

    Joined:
    Oct 2, 2012
    Posts:
    111
    Thank you, Justin.
     
  12. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Where is the footstep sound event triggered? I looked at the movement animations and don't see any events in there, where is the EventHandler.RegisterEvent<int>(m_GameObject, "OnTriggerFootDown", PlayFootstep); triggered? it isn't working for me
     
  13. russnash37

    russnash37

    Joined:
    Feb 22, 2017
    Posts:
    31
    I've been scratching my head over an issue all day and would be grateful of any help. In our project we are using the Opsive ThirdPersonController along with InventoryPro (with the provided integration in place) but, for some reason, player damage never seems to occur. For example, fall damage is enabled on the player but even when jumping off a high cliff in our terrain, no health or shield damage occurs. Additionally, any attempts to modify the health value through C# are also having zero effect.

    I'm sure I've done something wrong somewhere...
     
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    OnTriggerFootDown is executed within CharacterFootTrigger.OnTriggerEnter, when the trigger collider on the foot intersects with the ground.
     
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Can you insert a breakpoint/debug statement within Health.Damage? This should help indicate what is going on - I don't think the Inventory Pro integration is related since that doesn't affect the health at all.
     
  16. russnash37

    russnash37

    Joined:
    Feb 22, 2017
    Posts:
    31
    After some debugging as you suggested, the health value is changing, however, even when the value becomes 0 the character continues to live. So, a long fall is taking away all the characters health, they just aren't dying for some reason.
     
  17. KingLlama

    KingLlama

    Joined:
    Jul 18, 2015
    Posts:
    199
    I'm looking to set up swimming, What would be the correct way to do so?
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Have you added the Die ability? This will enable you to either use a ragdoll for the character's death or a specific animation. If you are using a ragdoll you'll need to make sure you've added a ragdoll using Unity's ragdoll builder.
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Looks like you posted this on the Opsive forum as well and Matt was able to help out :)
     
    KingLlama likes this.
  20. russnash37

    russnash37

    Joined:
    Feb 22, 2017
    Posts:
    31
    I do have the Die ability added and enabled, there is also a Ragdoll created for our character.

    Thanks for your help so far, it is appreciated.
     
  21. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Hmm.. can you set a breakpoint within Die.OnDeath to see why it's not enabling the ragdoll? The only thing that I can think of is that Ragdoll Death on the Die ability is disabled.
     
  22. russnash37

    russnash37

    Joined:
    Feb 22, 2017
    Posts:
    31
    After setting the breakpoint in Die.OnDeath as you requested, I can see that the function is not even getting called. It looks like the NotifyPlayerDied function in InventoryPro (InventoryPlayer.cs) is causing an unhandled exception which I'm assuming is preventing your Die.OnDeath function from being called?

     
  23. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    I'm still trying to add the first weapon to my character.
    When trying to create a new shootable item with the provided Item Builder, it seems all ok, but when running the scene in the editor I get all this errors:

    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[Opsive.ThirdPersonController.ItemType,System.Int32].get_Item (Opsive.ThirdPersonController.ItemType key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    Opsive.ThirdPersonController.Inventory.get_IsSwitchingItems () (at Assets/Third Person Controller/Scripts/Inventory/Inventory.cs:312)
    Opsive.ThirdPersonController.Inventory.SharedMethod_IsSwitchingItems () (at Assets/Third Person Controller/Scripts/Inventory/Inventory.cs:2221)
    Opsive.ThirdPersonController.SharedMethod`1[System.Boolean].Invoke () (at Assets/Third Person Controller/Scripts/Utility/SharedMethod.cs:58)
    Opsive.ThirdPersonController.RigidbodyCharacterController.SharedMethod_CanUseItem () (at Assets/Third Person Controller/Scripts/Character/RigidbodyCharacterController.cs:1353)
    Opsive.ThirdPersonController.SharedMethod`1[System.Boolean].Invoke () (at Assets/Third Person Controller/Scripts/Utility/SharedMethod.cs:58)
    Opsive.ThirdPersonController.CharacterIK.PositionHands () (at Assets/Third Person Controller/Scripts/Character/CharacterIK.cs:444)
    Opsive.ThirdPersonController.CharacterIK.OnAnimatorIK (Int32 layerIndex) (at Assets/Third Person Controller/Scripts/Character/CharacterIK.cs:243)


    Any idea?
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    It looks like something is getting hung up on the unequipped item type not being added to the item index map. If you can list the steps to reproduce from a fresh project I should be able to say what's causing it.
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Yeah, I bet once you fix the Inventory Pro error the die ability will work correctly.
     
  26. russnash37

    russnash37

    Joined:
    Feb 22, 2017
    Posts:
    31
    That was it! Fixed that issue and all is now working as it should, thanks for your help!
     
  27. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    I am having an issue with the offhand on the assault rifle animation. I created a new aim and shoot animation and added the event that was in the stock anims for those 2. When I aim and shoot, the left arm does not look like the animation position. I replaced this anim in the upper layer, left arm and right arm animator states. also i took out the offhand position in the assault rifle itself and tried with "Two Handed Item" true and false, but the arm still is straight to the end of the weapon.
    Any idea on what I might be missing?
     
  28. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    Steps (in a fresh project):

    1- Open the Item Builder provided wizard
    2- Select Item Type: AssaultRifle (Primary Item Type)
    3- Base: AssaultRifle (from your asset)
    4- Item Name: Assault Rifle
    5- Assign to: My Character, Hand: Right and I enable "Add to Default Loadout"
    6- Type: Shootable
    7 - I press Build (no errors until here).

    My character (created with the Character Builder wizard) has added all the abilities (I use Clean animator controller) and all the animations work ok.

    When running the scene, my character doesn't play any aim or shoot animation when pressing Fire1 or Fire 2 keys and I get all these errors:

    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[Opsive.ThirdPersonController.ItemType,System.Int32].get_Item (Opsive.ThirdPersonController.ItemType key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    Opsive.ThirdPersonController.Inventory.get_IsSwitchingItems () (at Assets/Third Person Controller/Scripts/Inventory/Inventory.cs:312)
    Opsive.ThirdPersonController.Inventory.SharedMethod_IsSwitchingItems () (at Assets/Third Person Controller/Scripts/Inventory/Inventory.cs:2221)
    Opsive.ThirdPersonController.SharedMethod`1[System.Boolean].Invoke () (at Assets/Third Person Controller/Scripts/Utility/SharedMethod.cs:58)
    Opsive.ThirdPersonController.RigidbodyCharacterController.SharedMethod_CanUseItem () (at Assets/Third Person Controller/Scripts/Character/RigidbodyCharacterController.cs:1353)
    Opsive.ThirdPersonController.SharedMethod`1[System.Boolean].Invoke () (at Assets/Third Person Controller/Scripts/Utility/SharedMethod.cs:58)
    Opsive.ThirdPersonController.CharacterIK.PositionHands () (at Assets/Third Person Controller/Scripts/Character/CharacterIK.cs:444)
    Opsive.ThirdPersonController.CharacterIK.OnAnimatorIK (Int32 layerIndex) (at Assets/Third Person Controller/Scripts/Character/CharacterIK.cs:243)
     
    Last edited: May 17, 2018
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Generally for these type of situations I debug by doing the following:
    • Disable CharacterIK
    • Enable "Debug State Changes" on the Animator Monitor
    • Reproduce the animation issue, look at the console/animator controller
    • If a state isn't being called then make sure it should be within the item animations inspector.
    • If the correct states are being called then you'll want to double check your animations to ensure they are all correct
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    There are no problems with those steps - my guess is some previous change with your character is causing the issue. I would start with a fresh project just so you can try to reproduce it there. You should then also be able to follow along with the video exactly as I do here and here.
     
  31. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,160
    I started with a fresh project and I have followed the videos exactly. My character has been created with your Character Builder, so I don't understand what is going wrong. Testing with only the default abilities the errors are the same.
    Sincerely, I think, you, as the asset developer, should know why I am getting those errors (obviously they are related to your asset operation) and, what they mean.
     
  32. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    This method helped me identify the issue. Thank you.
     
  33. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Is it possible to change two handed weapon and secondary hand position realtime? I created new animations which require specific hand placements depending on if the character is aiming or not. Also, on some animations I don't want to attach the hand because it causes unrealistic arm movement. I added a set to each of these in the Item script, but getting error when trying to change secondary hand position and also when trying to change if the item is 2 handed or not: Opsive.ThirdPersonController.Item.set_NonDominantHandPosition (UnityEngine.Transform value) (at Assets/Third Person Controller/Scripts/Items/Item.cs:95) The requested operation caused a stack overflow.
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    As an example from the left hand to the right hand or visa-versa? For that what you should do is create two items - one for each hand.
     
  35. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    No I mean the field "Non Dominant Hand" and "Two Handed Item" on the item which is shown on the weapon inspector. I need to turn it on and off in a script and also change the transform of the "Non Dominant Hand" through scripts, but I run into the error mentioned above
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Did you modify Item.cs? The Asset Store Version doesn't have a setter for that property:

    Code (csharp):
    1.  
    2. public Transform NonDominantHandPosition { get { return m_NonDominantHandPosition; } }
    3.  
     
  37. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Yes I modified it on both items, adding a setter, and when i call the set is when the error appears.

    Code (CSharp):
    1. public Transform NonDominantHandPosition { set { NonDominantHandPosition = value; }  get { return m_NonDominantHandPosition; } }
    2. public bool TwoHandedItem { set { TwoHandedItem = value; } get { return m_TwoHandedItem; }}
    3.  
    4. weapon.NonDominantHandPosition = handPosition;
     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    It sounds like your setter has an infinite loop ;) It should look like:

    Code (csharp):
    1.  
    2. public Transform NonDominantHandPosition { get { return m_NonDominantHandPosition; } set { m_NonDominantHandPosition = value; } }
     
    Last edited: May 18, 2018
  39. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Yeah, when you said that it made re revisit the code to double check as i did before for recursive code and I noticed:
    public bool TwoHandedItem { set { TwoHandedItem = value; } get { return m_TwoHandedItem; }}
    i had TwoHandedItem = value instead of m_TwoHandedItem. Doh.
     
  40. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    I'm getting a bunch of errors of the style:
    Code (CSharp):
    1. The type or namespace name 'UI' does not exist in the namespace 'Opsive.ThirdPersonController' (are you missing an assembly reference?) [com.unity.postprocessing.Runtime, Assembly-CSharp-firstpass, Assembly-CSharp-firstpass, com.unity.postprocessing.Editor]
    2. The type or namespace name 'RigidbodyCharacterController' could not be found (are you missing a using directive or an assembly reference?) [com.unity.postprocessing.Runtime, Assembly-CSharp-firstpass, com.unity.postprocessing.Editor]
    This doesn't seem to stop the game from running but was wondering what I'm doing wrong? I'm using v2 of the post processing stack.
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    What does the full call stack look like? I just tried a fresh project with just TPC and the post processing stack imported and it worked.
     
  42. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    I have been working with this for a couple hours now trying to determine the best way to do this. I have been modifying the rigidbody class. The approach I am considering is the following:
    1. Raycast downwards from the expected position from the current movement to find the height of the ground relative to the current position.
    2. using rigidbody.movePosition to move downwards to match the ramp height
    Do you see anything that might cause problems with this?
    the upwards movement is fine if i just disable gravity while moving on a slope. but obviously I can't do that in the other direction, and can't increase it because it would just pull the character down faster than wanted.

    So my question: where do you think the y distance for movePosition should come from? the position - movement of the next frame? How would I get that position to draw the raycast? would it be bottom of the collider + player movement in the x and z?
    Thanks for all the help.
     
  43. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    In order to truly answer this I would need to actually implement it myself to see how it plays, but I think you have the right idea. The direction of the move could be determined by the bottom of the character's collider subtracted by the position that the raycast hit.
     
  44. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    I'm not sure what's happened but everything seems to be suddenly ok. Now I just need to work out why my HAP3 horse moves backwards when my character hops onto it. Presumably something to do with either Rewired or Easy Main Menu or both!
     
  45. Niltsor

    Niltsor

    Joined:
    Jul 3, 2017
    Posts:
    4
    Hi!

    I have been looking at the asset and I am curious, I`ve been trying to see if while in third person you can have an option to have an aim sight similar to first person (like when you aim in uncharted or tomb raider the camera comes closer). I`m considering buying it but I just want to be sure of this first because it`s vital to my design.

    Thanks
     
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Thanks for taking a look at the Third Person Controller.

    You can change the camera state so it has first person perspective when you are aiming, but it's not a 'true' first person view, just a different camera position. We've been working on a version 2 which will have integration with UFPS and that will have the true first person perspective. This version is still looking good for a late July release. But if all that you want to do is change the camera offset then you can definitely do that with version 1.
     
    Niltsor likes this.
  47. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Hi Justin,
    I am wondering what triggers which layers to animate in the animator controller. When I aim, the base layer has the normal movements and the upper layer says that AIM is playing, but only the right arm and gun aim at the target it seems. The left arm and right arm are both still in idle, and it have the head and left arm kind of following the base layer movement instead of the aim animation, giving some weird looking aim animations when i run.

    How would i get all of the upper body to stick to the aim animation points? should the left arm and right arm be playing the aim animation instead of idle when aiming?
    Thanks
    __
    edit: let me clarify a bit more.. The head and left arm are in the position of the aim animation, but when moving left and right it seems that they move laterally much more than the right arm and gun, and they become un-synced causing the left hand to move outside of the grip of the assault rifle.
     
    Last edited: May 23, 2018
  48. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    This sounds like it could be related to one of two things:

    - CharacterIK
    - Item Animation Settings (http://opsive.com/assets/ThirdPersonController/documentation.php?id=118)

    I would first disable CharacterIK and see if it helps at all. If it does then it's likely related to the speed at which the IK limbs adjust to the new position. If disabling CharacterIK doesn't help then you'll want to triple check the animation states that should be playing.
     
  49. BigRookGames

    BigRookGames

    Joined:
    Nov 24, 2014
    Posts:
    330
    Thank you, when disabling the CharacterIK script all the transposes in the animations are correct. I messed with the values in the script and it seems that when I change the "Hand IK Adjustment Speed" or "Hand IK Weight" from 10 to 0 (any positive value causes the issue too) then the issue with hands and weapon mismatching disappears, but the character aims the gun about 45° upwards from the actual debug draw look ray, even when both the aim and non aim animations are the same. Any idea why it would want the arms and gun to point way higher than the animation has it?
     
  50. Razmot

    Razmot

    Joined:
    Apr 27, 2013
    Posts:
    346
    @opsive How's the UFPS/TPS2.0 merge & rewrite going ? Could you please post some progress news on this forum from time to time, like every 2 weeks ?
     
Thread Status:
Not open for further replies.