Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    A quick question about the horse controller. How easy is it to replace the free horse with another horse or even another quadraped altogether? My guess is that I would have to simply replace the horse model and to assign a different set of animations.
     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    That's correct. The animator controller that blitz uses is just a blend tree but if for example you want your horse to be able to jump then you'll need to add the jumping states.
     
  3. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    OK, thanks. Btw, is there going to ever be the ability for the character riding the horse to be able to attack while riding?
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    With the item animation system you shouldn't need a new ability, but the Ride ability would need to be modified to allow the character to keep the item equipped. It's mostly a matter of having the right animations, there really shouldn't need to be any code changes. I'll add it to the list.
     
  5. Daleneil77

    Daleneil77

    Joined:
    May 14, 2016
    Posts:
    2
    NullReferenceException: Object reference not set to an instance of an object
    Opsive.ThirdPersonController.PickupObject.OnEnable ()

    I get that error message When I add my item for pickup :(
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Can you import the source code and tell me which line is being called within OnEnable? I should then be able to tell you how to fix it.
     
  7. Daleneil77

    Daleneil77

    Joined:
    May 14, 2016
    Posts:
    2
    it's alright, I started the character all over again. (I think I made the error when I was assigning the weapon) If I do receive the error again I'll send it. Thanks :)
     
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    @icetec (Pit) created an integration with ICE Creature Control and I just uploaded the integration to the Integrations page. This integration is the same package that Pit posted a few days ago except it has one fix to work with version 1.3.1 of the Third Person Controller. Thanks again to Pit for doing the integration!

     
    julianr and Tinjaw like this.
  9. goldencruz

    goldencruz

    Joined:
    Oct 2, 2013
    Posts:
    94
    is there a demo for the sword and shield or an video I been looking for a nice melee combat
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Thanks for taking a look at the Third Person Controller. Yes, there is a demo. Go to the Clean Scene and press Enter. This will change characters so it uses the adventure character which starts with a sword and shield.
     
  11. goldencruz

    goldencruz

    Joined:
    Oct 2, 2013
    Posts:
    94
    has anyone integrated inventory pro with this with all the features like inventory crafting buying and selling if so how did to manage this. thanks
     
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
  13. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    Tryed this thing at work PC, before buying it at for home use. and found a sereous bug, as it seems to me.
    This nice addon works almost perfectly, unless you have MORE than one imput device,
    Say usb Logitech G13 keyset + usb keyboard + usb mouse makes it totally irresponsive to mouse axis inputs.
    Meaning yes, i can click nmouse buttons and it will respond, but it fails to see any X oy Y mouse axis inputs, despite simple scripts like
    mX = input,getaxis("mouse x");
    Debug,Log("x:"+ mX);
    sees axis movement and simple camera controller (Can post script if will help) works perfectly fine.
    As far as i understand it tryes to use G13`s analog joystick as main input and somehow it messes with mouse inputs.
    Any idea how to fix this ?
     
  14. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Sounds like the same issue I was having. Go into the Quality settings and make sure V sync is turned on for all levels of quality. It might not be the problem, but that's what fixed it for me when the mouse movement was unresponsive. Took me a long time to figure out. Then I realized it worked fine on a higher quality but not on lower so I checked out the quality settings and figured it out from there. No idea why V sync would affect mouse movement, but it was.
     
  15. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    And can you point me where to look for those Vsync settings?
    I mean like edit-project settings? or file-settings- somewhere else?
    Kind of sad to unplug -reboot each time:)
    Nevermind found it myself) Will check now

    Nope, added Vsync every blank - still no changes, Tryed on all types of settings, no change.
     
    Last edited: May 19, 2016
  16. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Under Edit/Project Settings/Quality
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Are you referring to the web demos or a built project? Your post made me relook at how controllers are handled and I've made a change so it's a lot simpler now. I'm uploading a new set of demos now which includes the change. I can send you the changed files if you send me a PM with your invoice number. If it is that the mouse movement is slow, @drewradley's suggestion is spot on.
     
  18. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    Ni
    Still no luck, It just ignores mouse cos IT SEES NO MOUSE!
    It changes all mouse axis into joystick ones) So if anyone knows a solution better then unplug-reboot-work i`ll be thankfull.
     

    Attached Files:

  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Try the web demo out to see if things are any better. If they are I can send you the changes if you send me a PM with your invoice number. If the web demo is not any better can you describe what the issue is in more detail?
     
  20. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    I`m refferind to build Blank scene project i tested on work PC with G13.
    And it`s not slow, it`s totally ignored at both X and Y axis.
    If used after clean boot(unplug-reboot all but usb keyboard and mouse) works perfectly fine thou.
    Till the moment G13 is plugged back in(
    I`ll send the request for invoice check printout to our accounts dept- think won`t take to long for them to get the details back.
    For now can help by experiments thou)

    Going to try web demos , gimme a min.

    Clean scene on web demo works almost fine, mouse Y is inverted:)

    Script i used to test "if it`s a unity or a TPC bug" (in wich mosue works like intended, just incase it helps)

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. // Very simple smooth mouselook modifier for the MainCamera in Unity
    4. // by Francis R. Griffiths-Keam - www.runningdimensions.com
    5.  
    6. [AddComponentMenu("Camera/Simple Smooth Mouse Look ")]
    7. public class SimpleSmoothMouseLook : MonoBehaviour
    8. {
    9.     Vector2 _mouseAbsolute;
    10.     Vector2 _smoothMouse;
    11.  
    12.     public Vector2 clampInDegrees = new Vector2(360, 180);
    13.     public bool lockCursor;
    14.     public Vector2 sensitivity = new Vector2(2, 2);
    15.     public Vector2 smoothing = new Vector2(3, 3);
    16.     public Vector2 targetDirection;
    17.     public Vector2 targetCharacterDirection;
    18.  
    19.     // Assign this if there's a parent object controlling motion, such as a Character Controller.
    20.     // Yaw rotation will affect this object instead of the camera if set.
    21.     public GameObject characterBody;
    22.  
    23.     void Start()
    24.     {
    25.         // Set target direction to the camera's initial orientation.
    26.         targetDirection = transform.localRotation.eulerAngles;
    27.  
    28.         // Set target direction for the character body to its inital state.
    29.         if (characterBody) targetCharacterDirection = characterBody.transform.localRotation.eulerAngles;
    30.     }
    31.  
    32.     void Update()
    33.     {
    34.         // Ensure the cursor is always locked when set
    35.         Cursor.lockState = CursorLockMode.Locked;
    36.  
    37.         // Allow the script to clamp based on a desired target value.
    38.         var targetOrientation = Quaternion.Euler(targetDirection);
    39.         var targetCharacterOrientation = Quaternion.Euler(targetCharacterDirection);
    40.  
    41.         // Get raw mouse input for a cleaner reading on more sensitive mice.
    42.         var mouseDelta = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
    43.  
    44.         // Scale input against the sensitivity setting and multiply that against the smoothing value.
    45.         mouseDelta = Vector2.Scale(mouseDelta, new Vector2(sensitivity.x * smoothing.x, sensitivity.y * smoothing.y));
    46.  
    47.         // Interpolate mouse movement over time to apply smoothing delta.
    48.         _smoothMouse.x = Mathf.Lerp(_smoothMouse.x, mouseDelta.x, 1f / smoothing.x);
    49.         _smoothMouse.y = Mathf.Lerp(_smoothMouse.y, mouseDelta.y, 1f / smoothing.y);
    50.  
    51.         // Find the absolute mouse movement value from point zero.
    52.         _mouseAbsolute += _smoothMouse;
    53.  
    54.         // Clamp and apply the local x value first, so as not to be affected by world transforms.
    55.         if (clampInDegrees.x < 360)
    56.             _mouseAbsolute.x = Mathf.Clamp(_mouseAbsolute.x, -clampInDegrees.x * 0.5f, clampInDegrees.x * 0.5f);
    57.  
    58.         var xRotation = Quaternion.AngleAxis(-_mouseAbsolute.y, targetOrientation * Vector3.right);
    59.         transform.localRotation = xRotation;
    60.  
    61.         // Then clamp and apply the global y value.
    62.         if (clampInDegrees.y < 360)
    63.             _mouseAbsolute.y = Mathf.Clamp(_mouseAbsolute.y, -clampInDegrees.y * 0.5f, clampInDegrees.y * 0.5f);
    64.  
    65.         transform.localRotation *= targetOrientation;
    66.  
    67.         // If there's a character body that acts as a parent to the camera
    68.         if (characterBody)
    69.         {
    70.             var yRotation = Quaternion.AngleAxis(_mouseAbsolute.x, characterBody.transform.up);
    71.             characterBody.transform.localRotation = yRotation;
    72.             characterBody.transform.localRotation *= targetCharacterOrientation;
    73.         }
    74.         else
    75.         {
    76.             var yRotation = Quaternion.AngleAxis(_mouseAbsolute.x, transform.InverseTransformDirection(Vector3.up));
    77.             transform.localRotation *= yRotation;
    78.         }
    79.     }
    80. }
     
    Last edited: May 19, 2016
  21. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    tested, updated preveous post, hope it helps to understand what`s happening:)
     
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    So we're making progress :)

    The mouse inversion related to the Input Manager. A new version of the clean scene has been uploaded - I'm uploading the other scenes now.
     
  23. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    Progress is allweys a good thing.
    Thou i still can`t figure out what it messes with in TPC, cos any other scripts i try work fine (tutorial cameras, or mouselooks from forums work fine).
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    The Third Person Controller uses its own scripts which was doing more more when a controller was connected than it needed to. If the web demos work on your end I can send you the changes after you send me a PM with your invoice number. So everything is working well in terms of the web demos?
     
  25. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    Tested out - works fine now - no inversoin of Y, and it gets axis quite fine on WEB clean scene demo now.
     
  26. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    One last question if you don`t mind , my current project is made with hardware like gaming mice and side-keyboards in mind, so if there`ll be other problems like this can i hope for this level of support?
    If yes then i`ll just buy personal license for myself not to be dependant on a firm for it)
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Yes, one of the things that we're proud of is the level of support that we provide. If you take a look at the opsive forum you'll see that we have a small community built up and most of the questions are asked there. Having a dedicated forum makes it a lot easier to search to see if your question has already been asked. In the specific case of multiple different controller types, I highly recommend that you get an input addon such as Rewired. The Unity Input Manager is pretty limited for handling controllers and the Rewired integration makes it a lot easier.
     
  28. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,013
    As a user of several of Opsive's assets including TPC, Behavior Designer, and now UFPS I can attest to the fact that I've received the best support from Justin for his products than any other asset I own. And I own a lot of assets.
     
    opsive likes this.
  29. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    You got me, will get personal lic for my own needs, think alongside with Behaviour designer.
    And thanks alot for all advice, info and support.
    Very glad to see such a nice authors on asset store:)
     
    opsive and magique like this.
  30. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    Done quick mode retest on Demo Empty Scene - it now has ALOT of random movement on 2.5d mode(
    And almost any mouse movement results a direction change from right to left or vicce versa.
    Looks almost same as if i used analog joystick and had 0 deadzone set)
     
    Last edited: May 19, 2016
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Thanks for letting me know. There was still some old code from the changes earlier today. A new clean scene is uploading - give it one more try (it should be uploaded within a couple of minutes)
     
  32. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    I'll get to test pc only closer to evening. Will try and report any results on empty scene behaviour as soon as will get to it)
     
    opsive likes this.
  33. arbt

    arbt

    Joined:
    May 22, 2013
    Posts:
    10
    I'm trying to integrate Inventory Pro with the latest version of TPC but as soon as I import the latest integration files I get the following error:

    Assets/Third Person Controller/Integrations/Inventory Pro/InventoryControllerBridge.cs(103,43): error CS0176: Static member `Opsive.ThirdPersonController.Input.PlayerInput.GetAxis(string)' cannot be accessed with an instance reference, qualify it with a type name instead
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    In version 1.3 the PlayerInput component changed from being static to an instance. You'll get that error if your using a pre-1.3 version with the latest Inventory Pro integration. Make sure you've updated to the latest on the Asset Store.
     
  35. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    Nope, it`s a bit better then before, but still can`t aim in 2.5d.
    I`m moving my mouse on the right (from character) side of the screen from top to bottom on a straight vertical line.
    And it recives hell lot of some "random" input and thinks that it`s on the left from the char (works same way - if i`ll make a line on left char side it`ll pop to right and will apply same strange behaviour).
    Same now applys to top down mode,
    (Recorded just now on current web demo of empty scene, most modes on same scene work fine now)
    Videos included with mouserecord on
    top down


    2.5 d


    PS one other thing. Maybe we should move this thread somewhere else to speak about this current problem?
    This is a VERY GOOD asset, and multy input problem (in my oppinion) is pretty rare case, and i don`t want to make this tread to confuse someone to think that TPC doesn`t work as intended.
    So i`ll be glad to move discussion to E-mail, your Opsive forum, or wherever you prefer.
     
    Last edited: May 20, 2016
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Sure, send me a PM or email (support@opsive.com) and we'll get it working. You're hitting a couple of rare cases where the logic needs to be different for the mouse versus the controller but you're using the opposite input than it expects. I have a couple of ideas on how to solve it, and I'll bounce the ideas off of you over PM/email.
     
  37. Silvermurk

    Silvermurk

    Joined:
    Apr 29, 2016
    Posts:
    164
    Justin is a codeing genius. Everything worls perfectly fine even with 2 keyboards, 2 mice and a joystick all at same time
    Vids included:)
    And THANKS ALOT, you made me choose this marvolous asset above all controllers for our release.
    (well even above makeing a team to code our own :p)

     
    magique, Xx-Dr-Pepper-xX and opsive like this.
  38. arbt

    arbt

    Joined:
    May 22, 2013
    Posts:
    10
    Thanks, that solved the issue, the latest version we got installed wasn't up to date somehow.
     
  39. SwiftIllusion

    SwiftIllusion

    Joined:
    Jan 22, 2012
    Posts:
    66
    Hello, I've just purchased this and hoped to test out the functionality of the multiplayer setup in the demo,
    however it seems very broken currently and I'd like to know if it just hasn't been kept up to date or?
    Using Unity 5.4.5f1 free version, built the demo network scene without any adjustment for windows 32bit, running on windows 10.
    I consistently, after running 2 instances of the game and hosting with 1/connecting as client via the other get 1 of 2 results:
    #1- The client ended up having control over both characters (shooting/moving-didn't affect the host game)
    #2- Camera and second character began floating upwards immediately after entering the scene (character stayed on ground-didn't affect the host game).

    I'd greatly appreciate knowing if this is a known issue or if there's some kind of further setup I've missed or if it's a bug?
     
  40. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    The only known issue is that a few of the object pool references are missing in the sample scene. Take a look at this post for that fix. Besides that I've tried the Asset Store version and things are running well. Make sure you follow the steps on this page
     
    SwiftIllusion likes this.
  41. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Hi Justin, thanks for all again, sorry for this invasive post but of all of you guys who use Horse Animset Pro and Opsive here is the tutorial for the new release.



    cheers
     
    SwiftIllusion, magique and opsive like this.
  42. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    That's awesome - thanks for doing the integration!
     
    Malbers likes this.
  43. SwiftIllusion

    SwiftIllusion

    Joined:
    Jan 22, 2012
    Posts:
    66
    Thanks a lot for the response Opsive. I added the object pool references-I think (https://i.gyazo.com/fb64f36ed3a651971623152fbc28fd13.png added it here in the network manager because the shown object pool script on the game object has no spawnable prefabs option-an newer version change or am I missing something?).
    Also even though I clicked to add the multiplayer symbol to the character controller, and it no longer shows up as an error on the actual character, it still comes up as an error in the console when I play the project and connect as a host - https://i.gyazo.com/c6e40de1bfdfcf0a92b0ba0b45c10d89.png
    Is there something more here I could be missing?
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    The only time that you'll continue to get that error even after clicking the add symbol button is if you don't import the source (step 2 from this page) or if you're targeting a platform which doesn't support UNET, such as the web player. Looking closely at the error there are no line numbers for RigidbodyCharacterController.Awake so the source isn't imported.
     
    SwiftIllusion likes this.
  45. SwiftIllusion

    SwiftIllusion

    Joined:
    Jan 22, 2012
    Posts:
    66
    Thanks so very much for another fast response. Sorry I completely missed the additional step of importing the source, that fixed it all up :)!! That also added the spawnable object option to the object pool script :).
    Also if I may ask, the multiplayer component has "LAN" for host and client, does this mean it's only connecting to local computers or can you still connect to it over the internet with a forwarded port?
     
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Yes, UNET can work over more than just LAN. Take a look at this link for an overview:

    http://docs.unity3d.com/Manual/UNetOverview.html

    The Third Person Controller network sample scene just contains the debug network interface for connecting to other machines so you'll need to expand on that
     
    SwiftIllusion likes this.
  47. SwiftIllusion

    SwiftIllusion

    Joined:
    Jan 22, 2012
    Posts:
    66
    Sorry to be asking for more support again so soon but I'm having a significant issue with the character builder using generic as the model type. I've looked at the documentation without finding anything I'm missing, and I've also tried to use your included character and horse for testing, however I'm having an issue where the framerate drops dramatically to 2-4 while making any action with the character/player movement-only when a generic character is built though.
    Using your included character mesh and building that as a humanoid caused no issue.
    While toggling various parts on/off to try and narrow down the cause I found that unticking/disabling the "controller handler" script on the mesh/newly set up character object fixed the framerate, though of course that also stopped me being able to control the character at all.
    Is there some additional setup for generic models or are they restricted in some way?
     
  48. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Can you profile it to see what the bottleneck is? The most likely cause with such a dramatic framerate drop is that something is outputting to the log every frame. This will instantly kill your framerate.
     
  49. SwiftIllusion

    SwiftIllusion

    Joined:
    Jan 22, 2012
    Posts:
    66
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Yes, the console log is causing the drop. What does the message say?
     
Thread Status:
Not open for further replies.