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

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
  2. drakekaz

    drakekaz

    Joined:
    Jan 16, 2014
    Posts:
    43
    @Gametyme Thank you. I'll try and check here first from now on. Although, I am getting a bug with the melee weapons when I import the source code. Has anyone experienced this? Check it out.

    NullReferenceException: Object reference not set to an instance of an object
    Opsive.ThirdPersonController.MeleeWeapon.AttackDirection () (at Assets/Third Person Controller/Scripts/Items/MeleeWeapon.cs:278)
    Opsive.ThirdPersonController.MeleeWeapon.Used () (at Assets/Third Person Controller/Scripts/Items/MeleeWeapon.cs:212)
    Opsive.ThirdPersonController.ItemHandler.OnUsed (Boolean primaryItem) (at Assets/Third Person Controller/Scripts/Character/ItemHandler.cs:317)
    Opsive.ThirdPersonController.EventHandler.ExecuteEvent[Boolean] (System.Object obj, System.String eventName, Boolean arg1) (at Assets/Third Person Controller/Scripts/Utility/EventHandler.cs:281)
    Opsive.ThirdPersonController.AnimatorMonitor.ItemUsed (Int32 primaryItem) (at Assets/Third Person Controller/Scripts/Character/AnimatorMonitor.cs:796)
     
  3. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    @drakekaz -

    Thanks for letting me know. Open MeleeWeapon.cs and change:
    Code (csharp):
    1.  
    2. #if !ENABLE_MULTIPLAYER
    3.   if (!m_IsAI.Invoke()) {
    4.   SharedManager.InitializeSharedFields(Utility.FindCamera().gameObject, this);
    5.   } else {
    6. #endif
    7.   m_CharacterTransform = m_Character.transform;
    8. #if !ENABLE_MULTIPLAYER
    9.   }
    10. #endif
    11.  
    to:
    Code (csharp):
    1.  
    2. #if !ENABLE_MULTIPLAYER
    3.   if (!m_IsAI.Invoke()) {
    4.   SharedManager.InitializeSharedFields(Utility.FindCamera().gameObject, this);
    5.   }
    6. #endif
    7.   m_CharacterTransform = m_Character.transform;
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    We had a booth at Unite yesterday and it was great meeting everybody. It was especially fun to talk to existing customers and see the games that are using our assets. During this time we introduced our next asset which will be a project that uses both the Third Person Controller and Behavior Designer. Here's a few early screenshots and a working project description and features of our next asset, the Deathmatch Kit.

    Deathmatch Kit

    ExperimentRoom.png
    ControlRoom.png
    BehaviorScreenshot.png

    The Deathmatch Kit is a complete project which allows you to create a free for all or team based deathmatch game. The Deathmatch Kit combines the power of Behavior Designer with the flexibility of the Third Person Controller.​

    Features:​
    1. Custom behavior tree tasks
    2. Complete weapon set
    3. Deathmatch rule system
    4. 2 PBR levels
    5. Sci-fi characters
    6. Combat animations
    7. Full menu system
    The Deathmatch Kit is in its early stages so everything could change but we hope to get it out later this year.
     
  5. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Looks awesome!
     
    opsive likes this.
  6. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    is it a multiplayer add on like for ufps multiplayer kit ?
     
  7. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I do plan on adding multiplayer, but probably not in version 1.0. There is a little bit of a difference between this and the UFPS multiplayer addon though - the UFPS addon is necessary in order to have any sort of multiplayer, whereas multiplayer support has already been added to both the Third Person Controller and Behavior Designer.
     
  8. GabeRodrigues

    GabeRodrigues

    Joined:
    Aug 20, 2014
    Posts:
    2
    Hello, i bought your asset and i'm having some trouble to make it work with photon network.
    When i try to get my character's animations to work with photon network's "Animator view component", the values are not updating correctly. For example, the value "forward input" of the animator, never updates, even when the player from another client moves. I'm activating the controller's scripts on only one character(local character) and observing from another client, but the animator's values are not changing.
    Do you guys have any idea on how i can fix it?
     
  9. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Unfortunately I'm not familiar with Photon so I can only say how it works with UNET. In UNET I attached the Network Animator component to the character and that component will automatically synchronize the parameters. UNET doesn't require you to do any parameter synchronization in code, but if you do need to in Photon then the place that the forward input parameter is set is within AnimatorMonitor.SetForwardInputValue.
     
    GabeRodrigues likes this.
  10. snackzilla

    snackzilla

    Joined:
    Aug 17, 2014
    Posts:
    91
    Woah the deathmatch style game looks great! Quick question! I've had this asset for a while but just got around to messing around with it. Following along with the documentation, importing my character and all that...

    Anyway, on the weapon positioning. When I position the item (in this case, the assault rifle) correctly in "Always Aim" mode, and copy the component values, it looks fine. However when I disable "Always Aim" and the character defaults back to Idle state, the item isn't positioned correctly in the hands. I'm using the default animations and items, only with my own character. Is there any easy way to fix this? Can I have two different positions for the item in "Idle" and in "Aim" state?
     
  11. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks!

    You shouldn't need two different positions. Can you post a screenshot of what it looks like in the aiming and idle state?
     
  12. snackzilla

    snackzilla

    Joined:
    Aug 17, 2014
    Posts:
    91
    idle-state.jpg aim-state.jpg

    Here you go! It's always positioned in the right hand correctly, it's just the left that's off. I've double-checked to make sure that the weapon is checked as a "Two-Handed Item" on IK as well. I've tried with two different characters, as I thought it may be the rigging on my first. This one is using Mixamo's default humanoid rig from Fuse.
     
  13. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks - those screenshots help a lot. It looks like the left hand is a little bit off on the aiming as well - from that view it looks like the hand is going through the weapon. The root cause is that every rig is slightly different. For example, if the arm length is slightly longer with the rig that the animations were made in compared to your rig then the default animations won't match up exactly. There are two solutions for this:

    1. Modify the muscle definitions to match your characters rig
    2. Use your own animations created for your character
     
  14. snackzilla

    snackzilla

    Joined:
    Aug 17, 2014
    Posts:
    91
    That's what I thought it was going to entail, I was just making sure there wasn't any kind of modifier in the Character script I was missing! Thanks Opsive! That will expedite my troubleshooting/fixing process. Great kit, by the way! I'm loving it so far.
     
    opsive likes this.
  15. GabeRodrigues

    GabeRodrigues

    Joined:
    Aug 20, 2014
    Posts:
    2
    Well i understand that you are not familiar with photon, i may give UNET a try. Thx for you support anyways and i love your asset, good job!
     
  16. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Hello I have a problem with TPC I'm Just discovering the package and when I setup a custom character the hands do not position good

    Does someone know how to fix it?
     
  17. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92

    It seems I didn't post the right link
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    There was a similar question a couple of posts up - take a look at this post for a description of what the problem is and two potential solutions.
     
  19. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Thank you for your reply.(sorry to ask this question a second time I thought it was an option like in ufps to link the weapon and a hand) I found a third "cheating way" I re-rigged my character because the bones has different proportions than Doug. Wonderful asset congratulation.
    It's not perfect but i'm going in the right way
    [/URL][/IMG]
     
  20. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
  21. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    That's also a good idea. It definitely looks better - just a few more tweaks and you'll have it!
     
  22. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    This looks great! I have a few questions before I purchase...

    Is there any 1st person mode? I liked how UFPS had that with full body awareness, when if you look down you see your chest/legs.

    You mentioned it's UNET ready; do you have any basic example scenes?

    Did you ever decide to integrate Final IK? If not, would it be difficult to use that instead of Unity's IK?
     
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Appreciate it!

    There is not a first person mode though I've gotten this question a lot. I have been trying to stay away from it and just focus on third person features since I feel like it would be tough to compete against UFPS. I'll probably end up adding it eventually though ;)

    Yes, there is a basic example scene included. There is no web demo for it but you can see a screenshot of what it looks like within the promo screenshots:



    I have not added FinalIK integration yet but I'd like to after version 1.1 is released (this update is huge so I'm trying not to add anything more to it :) ). I have heard of others using it without a problem though - just disable the CharacterIK component and then start to add the FinalIK components.
     
    redjon29 likes this.
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    So I know that dual wielding actually decreases your accuracy in real life, but we just got it working in our dev branch and it's so much fun to play with:

    DualPistols.PNG

    Right now both dual wielded items fire at the same time. I'm thinking that I'll make it an option to be able to fire the left or right weapon. With that said, what type of key mapping would you expect with this? Left mouse fires left weapon, right fires right, and you're not able to zoom?
     
    tmmandk and redjon29 like this.
  25. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Yes left/right mouse and cntl key for zoom?
     
    opsive likes this.
  26. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Dual wielding looks good i think the zoom should be turned off in dualW as you say doug loose accuracy with a gun in both hand and the zoom simulate aiming concentration.
    I have also some questions. I started using tpc about a week ago. When i build an item, a colt 1911 referred to the pistol item type and use pistol bullets. It works fine shot turret... But it doesnt appear in my character inventory nor the bullets. I had 10 bullets in the clip and that's all even if i place 50 in the inventory componment. The in game inventory doesn't show me my gun and ammo as well.
    Is there some tutorials to replace animations? Mine looks good with my character but in game it get stucks in aiming position after firing.
    Thank you
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for the feedback! For now I've disabled zooming and it's working really well. It would be a quick change to enable zooming again if you still want to be able to.

    It sounds like something is setup incorrectly with the ItemTypes. Ensure your ShootableWeapon on your colt GameObject is using the same ItemType as the one listed on the character's Inventory component. If you haven't seen it, here's the start of three videos which describe setting up a weapon. I recommend creating your own ItemType as the ones used within the default asset may change in an update and you may not necessarily want that change. In fact the Pistol ItemType is definitely going to change in the next release to support dual wielding.

    There is one extra step with replacing the aim animation. Take a look at this page for some more details - but my bet is that you need to add an animation event so the controller knows that the aim animation is complete and can fire the weapon. You'll need to add an animation event for the attack animation as well. Take a look at the AssaultRifleAttack clip for those parameters. I'll add a new How To page describing this as well.

    Edit: used how to page added.
     
    Last edited: Oct 1, 2015
  28. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Thank you very much it works fine. I didn't know about setting an ending marker on animation you are the best !!!
     
    Arganth and opsive like this.
  29. Artificialized

    Artificialized

    Joined:
    Oct 5, 2014
    Posts:
    69
    Hello Opsive thankyou for all your hard work and effort and time that you've put into this asset im currently testing out the point and click version of your asset and i cant figure out why my character keeps rotating in circles even when im not clicking for example i would click from point "a" to point "b" and after it reaches its destination it will do a repeating full 360 degrees circle i basically mimicked the point and click demo except the only things i changed were add a network identity to my character and add a network manager and network manager hud also my characters feet have a awkward look to them when in the idle animation the characters feet go in and out :eek: Also everytime i go to attack something such as the orange cube in the point and click demo my character continues to do the 360 degrees rotation and rarely plays the animation forgive me if i have my project setup wrong.

    Below are the errors i recieve




     
  30. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Hello Cascadex I think that you have to set your character as a target for your camera game object. Click on the camera then you will see a read warning there you will be able to set your character as target of the camera. The errors should be resolved.
     
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for helping @redjon29! Yeah, it looks like the camera needs a character assignment. If there is no character specified then it will automatically try to use the GameObject which uses the Player GameObject, but it doesn't look like that exists either. Once you get the camera errors fixed we'll see if the other problems go away.

    camera.PNG
     
  32. Artificialized

    Artificialized

    Joined:
    Oct 5, 2014
    Posts:
    69
    I've tried this last night a few times befor i posted my problem restarted unity a few times and then when i add my character to the camera target the camera doesnt follow :/ i've imported the source code dont seem to have any errors there not exactly sure what could be wrong whenever i go to attack a orange cube sometimes the bow animation plays but also sometimes they dont and most of the time when i try to attack the orange cube itll do a full 360 degree circle and keep repeating the circle its like its encountering a object in the way :eek: Could it be because im using a older version of unity?

    Using
    Unity version 5.1.3f1
     
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    The Unity version shouldn't matter - we still support 4.6. So you aren't getting the camera error anymore? From your original post, if the character is rotating 360 degrees after reaching the destination then it could be that the character is trying to reach the exact target position, and is cycling back and forth trying to get to that point. You can prevent this from happening by increasing the stopping distance on the NavMeshAgent.
     
  34. Artificialized

    Artificialized

    Joined:
    Oct 5, 2014
    Posts:
    69
    Nope im not getting the camera error anymore but now that i have the camera targeted on the character the camera wont follow my character and when i dont have the camera targeted on my character the camera follows my character :eek:
     
    Last edited: Oct 2, 2015
  35. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Is your camera set to Top Down for the View Mode? If it is, is it possible for you to either send me your project or list the steps to reproduce from a fresh project? As soon as I am able to reproduce it I should be able to figure out the problem pretty quickly.
     
  36. Artificialized

    Artificialized

    Joined:
    Oct 5, 2014
    Posts:
    69
    Yes my camera is set to top down for the view mode all i did was replace the doug top down/point to click character scene setup, and added my own networked character and added a network manager hud,and network manager script to a empty game object in the scene called Network Manager, i then proceeded to add my network character Gladiator to the network managers player prefab spawn.Also i removed doug from the scene and replaced him in the network manager player prefab spawn section.

    Also i'm not exactly sure how to send you my project files if it would be easier to do just that then i would rather do that then to have you spend to much time with this odd little error although at times i may seem to be unity asset illiterate i tend to comprehend things much better with trial and error i really appreciate your help you are so kind and giving and very knowledgeable :D

    Below is a few screenshots i took here's what mine looks like



     
    Last edited: Oct 2, 2015
  37. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Ah, you're using a networked scene. Since networking makes things a little bit more complicated it would probably be easier for me to just directly look at it. How big is your project? You could upload it to Dropbox and then PM the link to me.
     
  38. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    I might just pick this up. A question though, how robust is the networking that's included? I read this, but what functionality is actually included within your demo scene, and how do people connect to one another, or is that something I need to integrate?

    Thanks.
     
  39. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Awesome - the networking aspect covers everything on the character framework side of things. This means that it'll do things such as synchronize the character movement, firing a weapon, or starting an ability. It will also only send things over the network that need to be sent - for example, smoke particles from a firing weapon don't need to be synchronized across all of the clients so it will play that locally on each client.

    The demo scene contains a working example of this, but it doesn't include any of the menus. It uses the Unity NetworkManager debug GUI menu to connect to other clients. You can use the Unity Network Lobby Example as a more complex example of a networking menu scene and then load a scene which spawns a Third Person Controller character.
     
  40. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    Sounds really good! Is there anything in-place for player cheating, such as using Cheat Engine program as an example?
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    There is not, but some type of integration with AntiCheatToolkit would probably be the best for that side of things. AntiCheatToolkit is integrated with Behavior Designer - I'll contact the author to see what it would take to add to the Third Person Controller.
     
    Last edited: Oct 3, 2015
  42. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    If you don't mind getting in touch with him, I I would appreciate it.
     
  43. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I just heard back from the ACTk developer. Here's what he said:

    That last part is what I was afraid of. Using the compiler definition would work, but it would really reduce the cleanliness of the code. It was also make maintenance a lot harder.
     
    Last edited: Oct 3, 2015
  44. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Hello, I have a hard time adding the pistol (like you show in your videos on opsive.com). I followed the videos step-by-step but after I "build item" the pistol is not automatic set into my character right hand. Its still a separate item in the hierarchy and when I test run Iam getting the following error

    NullReferenceException: Object reference not set to an instance of an object
    Opsive.ThirdPersonController.Item.Awake ()
    Opsive.ThirdPersonController.ShootableWeapon.Awake ()

    ArgumentNullException: Argument cannot be null.
    Parameter name: key
    System.Collections.Generic.Dictionary`2[System.Object,System.Collections.Generic.Dictionary`2[System.String,System.Delegate]].TryGetValue (System.Object key, System.Collections.Generic.Dictionary`2& value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:588)
    Opsive.ThirdPersonController.EventHandler.UnregisterEvent (System.Object obj, System.String eventName, System.Delegate handler)
    Opsive.ThirdPersonController.EventHandler.UnregisterEvent (System.Object obj, System.String eventName, System.Action handler)
    Opsive.ThirdPersonController.ShootableWeapon.OnDisable ()
     
  45. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    The videos are accurate for the current version so I would try one more time with a clean project. If it still doesn't work can you extract the source and let me know which line numbers the errors are occurring on? This will tell me more specifically what is going wrong. Based on that stack trace though it looks like it is something with the ItemTypes not being assigned.
     
  46. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    I try now again with clean project. Before was clean aswell but I had installed playmaker. Without playmaker its working. Thank you
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I'm glad that it's working :) Playmaker shouldn't cause any problems so you should be able to add it again if you want to.
     
  48. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,419
    Hello opsive. Could you please make a tutorial how to make the pistol with flashlight and laser? I tried to copy/paste the flashlight and laser from your topdown example but it did not work. My pistol which I created after your video arnt firing too :( The asset is awesome but I with there would be a little bit more explained about the demo scenes. How to accomplish since we can't simple copy / reuse the prefabs (wich I tried).
     
  49. DigitalAdam

    DigitalAdam

    Joined:
    Jul 18, 2007
    Posts:
    1,202
    Thanks for looking into this.
     
  50. redjon29

    redjon29

    Joined:
    Jul 12, 2015
    Posts:
    92
    Devision if you followed the tuto your gun fire but you don't see the fire and hear the sound. Select your pistol game object, in the inspector you will find many options where you can assign a sound, a muzzleflash, decals, flashlight laser...
     
Thread Status:
Not open for further replies.