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

    Candescence

    Joined:
    Aug 26, 2014
    Posts:
    107
    Looking good!

    Also, since weapons are among your next focus, I found this particular asset you could look at for ideas for things to add to the to-do list. The number of features and versatility of that weapons system is insane.
     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for the link! That asset really does have a lot of options - I'll take a closer look at it when I get to that part.
     
  3. den3d

    den3d

    Joined:
    Nov 23, 2014
    Posts:
    45
    Open Adventure scene, get Katana, press & hold fire button.
    You will see first animation slash right to left then second anim (left-right) looks weird.
    It could be fixed by Katana's params tune or require code change?
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    That was an example of showing multiple attack modes. You can open the Katana's MeleeWeapon component and remove the second Use state.
     
  5. Venged

    Venged

    Joined:
    Oct 24, 2010
    Posts:
    500
    Will you be adding swimming?
     
  6. den3d

    den3d

    Joined:
    Nov 23, 2014
    Posts:
    45
    I mean transition between those states jitter when hold fire button down.
     
  7. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yes, swimming will be added in version 1.1 which will be the next release.

    I'm not able to reproduce it - does the web demo have the jitter? The transitions are quick and the sound plays too much so I'll fix that but I'm not seeing a jitter.
     
  8. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    viddy for the win.

    What should that say? here: http://www.opsive.com/assets/ThirdPersonController/documentation.php?id=76

    Somewhat light on the networking docs...
     
  9. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I just read sentence about three times thinking that there was nothing wrong with it. I then realized that I repeated NetworkingTransform twice. Thanks, it should say NetworkIdentity, NetworkTransform, and NetworkAnimator. Note that the Character Builder will automatically add these components for you if you selected "Is Networked" in the first window.

    In terms of the docs, that's really all that is specific to the Third Person Controller. The rest deals with general UNET concepts which I linked to the overview of at the start of the doc.
     
  10. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    ultimately I think this is a good fit for your AI and Adventure set.

    A simple Hide and Seek Title

    upload_2015-8-30_2-50-38.png

    There is a very limited Roam area and easy to navigate NavMesh

    upload_2015-8-30_2-53-32.png

    A good fit you think?

    Gratefully accept any and all tips as usual - thanks.

    upload_2015-8-30_2-56-10.png
     
  11. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Have you looked at UMA 2 at all?

    The procedural runtime bones and mesh and avatar are giving me a headache...

    Okay UMA2 update:

    This is the single place where it currently applies post rigging.

    upload_2015-8-30_13-37-9.png

    A single /equivalent/ call (or calls) to rig the thing via script would seem to just be placed here...

    Any clues where I might start sir/madam?
    Additionally, I appreciate it is the weekend, no rush.
     
    Last edited: Aug 30, 2015
  12. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    It does - you wouldn't even need that complicated of a behavior tree for that. Have you seen the Third Person Controller behavior tree overview? It gives a pretty good explanation of the decisions that I made to get the AI working - you would be able to follow a pretty similar format.

    I haven't used UMA yet but @hopeful gave a pretty good overview of what it would take here. If you look at the Character Builder's BuildCharacter method you'll see what Third Person Controller components need to be applied. Everything within this method can be accessed at runtime so you should be able to bring the code over.
     
  13. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Yeah, that is what we thought.

    I found the right event where the bones and avatar will be available, I just need it to run through an autorig at that point.

    Seems like it should be pretty trivial if only I knew which bits to point where.

    Will work on it.

    EDIT: Yeah, Hopeful is talking about the OnDnaApplied event, which ecurtz has confirmed is the right place. There is even a replaceable LOCOMOTION script that is included with a single line... that we can just hijack.

    It really is that simple. I feel like it should be doable. And not too hacky. And would certainly add retail value to your solution.
     
    Last edited: Aug 30, 2015
    hopeful likes this.
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I am looking through UMA now. How is OnDnaApplied called? I did a search within the project and there were four references to it (all from files within the AdditionalSlots folder), but no calls to it. For the next version I could move the Character Builder's BuildCharacter code from the editor assembly to the runtime assembly. This will allow you to call it directly within the OnDnaApplied callback instead of having duplicate code.
     
  15. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Awesome.
    I have reverse engineered your editor class to do pretty much that for now.

    I will post a screenie in one sec for the location. (just woke up)

    EDIT: Okay I was butchering here:

    upload_2015-8-31_10-32-28.png

    LocomotionSlotScript.cs is called by the LocomotionRecipe (Which Attaches the slot, Which calls the prefab, Which contains the script LocomotionSlotScript.cs).

    I just started hacking there as it was the most obvious place. My mighty 48 hours of experience with UMA is really shining through huh...

    as ecurtz was saying

    • Setup Events directly in Unity
    The new event features in Unity 4.6 allows us to set up OnCharacterCreated, OnCharacterUpdated and OnCharacterDestroyed events directly in the Unity Editor making it much easier to work with UMA.

    So I will look into this when my current hackery fizzles out ;)
     
    Last edited: Aug 31, 2015
  16. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Awesome, that seems straight forward enough. I'll move the character creation method into the runtime in version 1.1 and have a basic UMA example. I'll try to do it the 'proper' way with the Unity events.
     
    twobob likes this.
  17. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Yay I love you.

    heh. Don't tell the missus

    EDIT: I have abandoned my efforts until the 1.1 drop therefore.

    No point duplicating effort.
     
    Last edited: Aug 31, 2015
    opsive likes this.
  18. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Can I make a final suggestion. When we add like Climb Abilites to one thing, perhaps the option of propagating those changes to the next model would save a great deal of time. - or similar, better thought through than my idea, functionality

    I seem to spend a /lot/ of time configuring the same abilities again and again.
    Many thanks.
     
    hopeful likes this.
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Maybe some type of copy/paste system like Unity has within the component inspector?

    copy.png
     
    twobob and hopeful like this.
  20. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    that would be awesome
     
  21. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
  23. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Might I very briefly enquire how one is to actually install the source code (I have it downloaded, I am on 5.1.3f1, I have BD installed) , whenever I try to install it I get dupe dll's and a bunch of errors...

    Sorry to be a pain :(
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    For third person? http://opsive.com/assets/ThirdPersonController/documentation.php?id=50

    For Behavior Designer, you can completely delete the Behavior Designer directory and then import.
     
  25. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    BD. Will do that right now.

    I delete everything. BD folder.

    Stuff in Plugins.

    I import Source.

    I get:

    upload_2015-8-31_21-40-2.png

    Happy to throw this onto the right thread
     
    Last edited: Aug 31, 2015
  26. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yeah - go ahead and post that in the Behavior Designer thread to keep this one focused on third person. I'll try it in Unity 5.1 as well.
     
  27. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Okay buddy. thanks

    For reference this is the position the player enters occasionally when brushed by NPC's

    upload_2015-9-1_1-6-1.png

    and is subsequently unable to walk.

    It might make sense to just "enable" falling in scenarios where "non-grounding" has occured for great than - say - 2 seconds. It would mitigate these scenarios and recover elegantly from currently unrecoverable blend tree positions (i.e via re-grounding).

    Allow for scenarios like accidental de-grounding more robustly.

    upload_2015-9-1_1-10-43.png


    Just a thought.
     
    Last edited: Sep 1, 2015
  28. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    I /am/ defining the symbol right aren't I?

    upload_2015-9-1_4-54-1.png

    The below is a the /totally/ virgin project (with the junk added back in gradually)

    upload_2015-9-1_4-56-52.png

    it seems to explode at the point of defining the symbol...

    it that a clue? There is more than one symbol, if that matters

    EDIT:

    Last clue. Even with all the Behavior Designer stuff removed I stll get

    upload_2015-9-1_5-17-28.png

    and that is with a single prefab in the whole project, only just made by character creator.
    And the symbol is defined. I tried both orders.
    This is something funny going on with the detection of the symbol perhaps.

    Next I might rip UDEA, but it worked fine with that before...
     
    Last edited: Sep 1, 2015
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    What type of collider is the ground? It looks like the SphereCast is failing to find the ground to stop the fall animation. I've seen this happen before in Unity 5 with planes, but since you are on terrain I would think that you are using a MeshCollider.

    What does the FemHumanoid prefab look like? Does the RigidbodyCharacterController have a "Add Multiplayer Symbol" button?
     
  30. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Okay, so we may have found the issue in the "Fresh" project, - could it /possibly/ be that we have used the wrong version of the sourceCode Download?

    I only just noticed that it is NOT versioned... Please can I ask that you add a version number to the SourceCode Download. I think that is the problem PEBCAC FUBAR based on replacing mismatching bits of code?
     
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    What's the timestamp on the source code package? Did you download it again after 1.0.2 was released? Also, the "Add Multiplayer Symbol" button comes from an editor script so it is included with the Asset Store package.
     
  32. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Well the size was wrong mate - that was my first clue ;)

    270k not 282k. We have the right one now.

    Also the blummin BehaviourDesignerSource isn't versioned neither... How about a "__I_AM_VERSION_1.5.2a.TXT" at the top of the file. That way when you open it for import it will be IDIOT-PROOF!!! (Okay dumbwit resistant)

    Am working on checking all my versions at this time.
     
  33. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Thinking about it: Our install of Third Party Controller was of 1.0.1 - and then you released 1.0.2 (which went unoticed by us) - we then went to get the Source (which is now 1.0.2).... Horror ensued.

    Sound about right? That actually is a perfectly reasonable set of events...

    BIG WARNINGS, VERSION TXT, MORE WARNING... et cetera ;)

    So - that is one stupid error fixed. User error that one I think.

    Back over to behaviour designer Source, see if I can figure that out (and yes I checked I have the latest)
     
    Last edited: Sep 1, 2015
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    That's not a bad idea, I could instead include a version info within the source and if that doesn't match the editor version, it'll throw an error.
     
    hopeful and twobob like this.
  35. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    upload_2015-9-2_19-10-59.png

    Heh. So it's which one is 27 again?
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    The screenshot is correct - layer 27 should be cover (though as long as you assign the Layermask correctly within the ability then it doesn't matter)
     
  37. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Thanks J.

    We have spent more time today working with the AI stuff, and have it working now without any actual "errors".

    Just attempting to get the operation to our liking.
     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    That's great to hear - I was starting to get worried that everything was actually working because I only saw one post from you today ;) Let me know if I can help with anything else!
     
    hopeful likes this.
  39. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    Not sure if this has already been covered. In the "Adventure" demo, at the part where it says "Crawl" on the ground to crawl through the tunnel, there's a problem. If I hit C it lowers the player into the crawling position, but as soon as I hold W or UP ARROW she stands up again. I can't figure out how to stay in a crawl position while moving.

    Seriously considering purchasing this package but before I click "buy" I wanted to verify whether this is a bug in the package itself, a bug in that particular demo, or if it's just something weird going on on my end.

    Secondly, I assume it's not too difficult to use my own animations for motions (walking, running, etc.) but I'm asking just to make sure. Anyone have thoughts about that?

    Thanks!
     
  40. UnleadedGames

    UnleadedGames

    Joined:
    Feb 17, 2008
    Posts:
    242
    Ony, I can confirm I have the same bug, or misunderstanding of how it works.
     
    Ony likes this.
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Thanks for taking a look at the Third Person Controller and letting me know about this bug. I've uploaded a new adventure demo which has the fix. It's a really small change - I forgot to add the movement state to the Height Change ability so it was defaulting to upright movement. You can fix this by changing the Movement State field:

    crawl.png
    That's right, it uses mecanim so all you have to do is replace the clips within the blend tree.
     
    UnleadedGames and Ony like this.
  42. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    Ok great, thanks for the fast response. I'll take a closer look!
     
  43. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    I would appreciate a heads up on the versioning as I am a bit unsure.
    Is the Asset Store 1.0.2 version the same as the Source Code release version, many thanks
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    Yes, the source code download will always match the version that is on the Asset Store. In version 1.1 I will add a little check as you suggested so you can ensure that you are using the correct version.
     
  45. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Okay. I only double checked so that I didn't mess it all up again on this new project :)

    Thanks mate.
     
  46. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    One quick possible demo bug report. (EDIT. See fix in next post)

    In the NETWORK demo if one selects FIST and attempts to punch

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Opsive.ThirdPersonController.NetworkMonitor.RpcExecuteItemEvent (Int32 itemID, System.String eventName) (at Assets/Third Person Controller/Scripts/Character/NetworkMonitor.cs:156)
    3. Opsive.ThirdPersonController.NetworkMonitor.InvokeRpcRpcExecuteItemEvent (UnityEngine.Networking.NetworkBehaviour obj, UnityEngine.Networking.NetworkReader reader)
    4. UnityEngine.Networking.NetworkBehaviour.InvokeRpcDelegate (Int32 cmdHash, UnityEngine.Networking.NetworkReader reader) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkBehaviour.cs:328)
    5. UnityEngine.Networking.NetworkBehaviour.InvokeRPC (Int32 cmdHash, UnityEngine.Networking.NetworkReader reader) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkBehaviour.cs:109)
    6. UnityEngine.Networking.NetworkIdentity.HandleRPC (Int32 cmdHash, UnityEngine.Networking.NetworkReader reader) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:472)
    7. UnityEngine.Networking.ClientScene.OnRPCMessage (UnityEngine.Networking.NetworkMessage netMsg) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/ClientScene.cs:609)
    8. UnityEngine.Networking.NetworkMessageHandlers.InvokeHandler (UnityEngine.Networking.NetworkMessage netMsg) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkMessageHandlers.cs:84)
    9. UnityEngine.Networking.LocalClient.ProcessInternalMessages () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/LocalClient.cs:136)
    10. UnityEngine.Networking.LocalClient.Update () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/LocalClient.cs:64)
    11. UnityEngine.Networking.NetworkClient.UpdateClients () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:709)
    12. UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:756)
    I am digging into it.
    Code (CSharp):
    1.         /// <summary>
    2.         /// Execute an event on the client. Items will call this method because the items do not have a NetworkIdentifier and cannot call Rpc methods.
    3.         /// </summary>
    4.         /// <param name="itemID">The id of the item executing the event.</param>
    5.         /// <param name="eventName">The name of the event to be executed.</param>
    6.         [ClientRpc]
    7.         private void RpcExecuteItemEvent(int itemID, string eventName)
    8.         {
    9.             EventHandler.ExecuteEvent(m_ItemWithID.Invoke(itemID).gameObject, eventName);
    10.         }

    EDIT: Switching to the knife has the same effect.

    When we add some debug for the pistol shot we get

    upload_2015-9-9_12-29-5.png

    however if we switch to FIST and try to punch we get:

    upload_2015-9-9_12-30-10.png

    Which as you can see never hits the debugging...
    Will have to follow it back down the rabbit hole.

    upload_2015-9-9_12-48-46.png

    It certainly seems like finding the reference to the ItemID associated with FIST is failing.

    I should try just invoking it next I suppose, see if fails at that stage or at lookup.

    Ongoing.

    Couple of other demo tidy-up points

    The grenade prefab referenced by the Network demo points to the grenade in third person shooter?
    (also it uses a deprecated null naming convention by default, which we have adjusted our side)

    upload_2015-9-9_12-14-3.png

    We think it should reference the network one.

    upload_2015-9-9_12-15-34.png

    EDIT:

    I can confirm this allows grenades to spawn and explode.

    I did wonder why the Default Loadout paramaters didn't auto-populate any missing items into the relevant hands - I also wondered why the default loadout section didn't have handedness (and a null-handed) embedded within it, since it seems to be pretty much the same data and could save running the item populator (or that's how it seems)

    Enjoying the product, just trying to work through the steps so we are 100% ready to run a clean project.
     
    Last edited: Sep 9, 2015
  47. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Okay so long story short.

    Seems like the FIST item was not in the loadout?

    upload_2015-9-9_13-54-28.png

    After checking it was there, and in the items in our hands, the errors went away.
    Knife is also fixable in this way.

    ALSO: It would be nice to choose the default weapon here... not just select the last added.

    Or at least let me reorder them ;)

    upload_2015-9-9_14-5-49.png

    We also noted that the Grenade Launcher Pickup doesn't seem to have an item attached?

    upload_2015-9-9_14-9-37.png

    Many thanks
     
    Last edited: Sep 9, 2015
  48. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    And. Hopefully Finally: Here seems to be the error in the Object Pooling

    upload_2015-9-9_14-44-56.png

    This seems to occur because a weapon is being allowed to fire /before/ it's default re-shoot time - and during this period the missiles do not actually get registered for events - until the next valid time to shoot and then it works again for one shots period (or until that missile is destroyed)

    Does any of this sound like it makes sense to you?
    Anyway, some sort of error in the pooling. possibly linked to the logic for "CanFire" or something.

    EDIT: Okay this appears to be linked to:

    upload_2015-9-9_15-9-48.png

    When the fire rate is too low the errors creep in.


    Cheers.

    And this is what we did to get the CharacterRespawner to work.

    Code (CSharp):
    1.         /// <summary>
    2.         /// Static method for returning a random spawn location from the spawn location list.
    3.         /// </summary>
    4.         /// <returns>The Transform of a random spawn location.</returns>
    5.         public static Transform GetSpawnLocation()
    6.         {
    7.             if (Instance == null)
    8.             {
    9.                        
    10.                 Debug.Log("Remind me why Instance is null again in SpawnSelection.cs?");
    11.  
    12.                 GameObject bob = new GameObject();
    13.                 bob.transform.position = Vector3.zero;
    14.                 bob.transform.rotation = Quaternion.identity;
    15.                 return bob.transform;
    16.          
    17.             }
    18.  
    19.  
    20.             return Instance.GetSpawnLocationInternal();
    21.         }
     
    Last edited: Sep 9, 2015
  49. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Hi. Pursuant to this could you please demonstrate reusing animations from one character to another.

    Something simple like - say - putting the BOW from Naomi onto Network Doug.
    We gave it a go (doing the obvious - copying the animations into the controller, creating the relevant items)
    However the animation was very far askew.

    Much obliged.
     
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,122
    I'm looking at the networking issues but this one is quicker. Naomi uses the Adventure controller while Network Doug uses the Shooter controller. To transfer the animation from one controller to the other all you have to do is copy the states. Make sure you copy both the base layer and the upper body layer. Beyond that, what results are you getting?
     
Thread Status:
Not open for further replies.