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

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    I have so far :

    Code (CSharp):
    1.  // Add the jump and fall abilities.
    2.             var controller = umaData.gameObject.GetComponent<RigidbodyCharacterController>();
    3.             AddAbility(controller, typeof(Abilities.Fall), string.Empty, Abilities.Ability.AbilityStartType.Automatic, Abilities.Ability.AbilityStopType.Manual);
    4.             AddAbility(controller, typeof(Abilities.Jump), "Jump", Abilities.Ability.AbilityStartType.ButtonDown, Abilities.Ability.AbilityStopType.Manual);
    5.             AddAbility(controller, typeof(Abilities.SpeedChange), "Sprint", Abilities.Ability.AbilityStartType.ButtonDown, Abilities.Ability.AbilityStopType.Manual);
    6.  
    sprinting works now when I press the sprint button, but now the character sprints forever, how can I have him sprint only when the sprint button is down? If released he should go back to walking..
     
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    If you take a look at the comments above the AddAbility method it'll explain what each argument is for. I'm guessing the confusion is in the Start/Stop type? For those the easiest way would be to look at this forum post which has the default values start/stop types for all of the abilities. Another way would be to look at one of the existing demo scenes to see what value it uses. Swimming would use:

    Swim
    Start Type: Manual
    Stop Type: Manual

    And the SpeedChange:

    Speed Change
    Start Type: ButtonDown
    Stop Type: ButtonUp

    Manual means the ability is programmatically started/stopped. In the case of the swimming ability the Water component will do the starting/stopping so that's why they are both manual. SpeedChange should be started when the button is down and it should be stopped when the button is back up.

    Take a look at the Environment/Water/Water4Example/Water GameObject within the CleanScene for an example, but your water should have the Water component along with a trigger. When the character enters this trigger it will try to start the ability, and when the character leaves the trigger it will try to stop the ability.
     
  3. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I just tried this on a scene with some rough terrain and the player starts to bounce uncontrollably rather a lot - mostly when I jump but other seemingly random times as well. I think it's getting stuck in a landing state, but according to the animation graphs, it's in idle on all layers.
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Try to decrease the Step Speed on the RigidbodyCharacterController.
     
  5. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I put it all the way down to .1 and it still happens.
     
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Can you send me the terrain file so I can try it out?
     
  7. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I'm using the ORK demo scene - 01 Town. No changes. Do you still need me to send it to you or do you still have it?
     
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    I think that I know what you're talking about on that one. If you decrease the CapsuleCollider radius to a smaller size, I think that I remember a radius of 0.15, then it works a lot better. The CapsuleCollider was getting stuck in the terrain and Unity physics was pushing it in odd directions. When you decrease the size of the CapsuleCollider then it doesn't get stuck.
     
    drewradley likes this.
  9. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    That totally fixed it! The skinny capsule collider won't be a problem with going into walls?
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    How skinny did you have to make it? Does it still cover the character? When I tested it I was able to make it wide enough to be able to still cover the character. I'll write down trying to look for a better fix for this because you could have a large character regardless and you wouldn't want to have to have a smaller CapsuleCollider.
     
  11. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I made it .15 like you suggested. :) It sort of covers the player mesh, but the shoulders stick out a bit and a little bit around the hips.
     
  12. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    I really like the looks of your latest update. I may have to purchase this asset!
     
    opsive likes this.
  13. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Just giving you a heads up I have a fix for this situation. You will be able to have a collider radius of any size in the next version and the ORK terrain will work without a problem. I think that we should be able to release an update later this week.
     
    Last edited: Jan 17, 2016
    drewradley likes this.
  14. TonanBora

    TonanBora

    Joined:
    Feb 4, 2013
    Posts:
    493
    Hey Justin,
    I am trying to create a more simple jump with just an idle jump, and a running jump.
    However, I have set up the states, and created my "SimpleJump" ability, but when I try to activate it, nothing happens.
    I debugged it, and it seems to go through the ability activation, but the animation does not play.
    Animator setup:
    Screen Shot 01-17-16 at 01.37 PM.PNG
    I have the same setup in the upper layer as well.

    SimpleJump Ability:


    Code (CSharp):
    1. public class SimpleJump : Ability {
    2.  
    3.     public override string GetDestinationState(int layer)
    4.     {
    5.         return "SimpleJump.Jump";
    6.     }
    7.  
    8.  
    9. }

    Ability Settings:
    Activation: Button Down ("Jump").
    Stop: Automatic
     
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    A stop type of Automatic will have the controller call CanStopAbility which by default returns true. Your ability is probably starting and stopping all within the same frame. If you override CanStopAbility similar to how the regular Jump does it the animations should then play.
     
  16. TonanBora

    TonanBora

    Joined:
    Feb 4, 2013
    Posts:
    493
    Hmm, well, I am not sure how to do it similar to the way the regular one does it, as I am not exactly sure what I need, and don't need from the regular one.

    I do not need to detect a trailing foot, nor do I need to watch for double jumps.
    But I am still not sure what it is I need to include. I took the regular jump ability, coped its code over and took out what I thought I did not need, and modified the state references to point to my animation. Now the animation plays, but does not stop.
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    It sounds like you need to add in the CanStopAbility method, and then set the Stop Type to Automatic. For this to work you'll also need to add the m_Jumping variable as well as the methods that it is set in (OnGrounded, OnStartJump, and AbilityStopped)
     
  18. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    is it possible to swim in a volume, instead of on a flat plane?
     
  19. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Do you mean being able to dive underwater? Or swim on top of waves?

    Diving is on my ability list, and swimming on top of waves will probably take an integration because Unity's water doesn't allow for waves.
     
  20. TonanBora

    TonanBora

    Joined:
    Feb 4, 2013
    Posts:
    493
    I posted some more questions/information on the Opsive forum, since my post would contain some code that I am not sure you would like posted here or not. Figured I would err on the side of caution. :)
     
  21. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    200
    Hey, I have another question. I'm using the third person camera with adventure controls. I wanted to ask, can I rotate the camera over the character. Live 45 degrees overhead view.
     
  22. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214

    I just mean dive, so instead of swimming straight on top of a collider, maybe be able to swim inside of a box collider volume. up and down on the Y axis
     
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Do you mean restricting the pitch to 45 degrees? Yes, there's an option that allow you to restrict the pitch within the CameraController inspector.

    Makes sense - yes, diving is on the list :)
     
  24. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    200
    Do you mean the pitch limit? I did that but the camera collides and zooms in and out.
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Yes - if you set the pitch limit then the camera will stay at that pitch. If there is an object that would be obstructing the view it will move into to prevent the obstruction but the pitch stays the same.
     
  26. namdo

    namdo

    Joined:
    Feb 23, 2015
    Posts:
    200
    Is there a way to stop it from that zoom in
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    In the next version I have added a field which will allow you to specify a LayerMask of the objects that you want the camera to ignore for its obstruction check. Take a look at this post for an overview of the change.
     
  28. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    Opsive I have gone through the weapon system and I have to congratulate you on creating one of the more eligant animation systems out there. Really really good stuff man. I have been banging my head for a few months trying to do what you have done.

    I have a few observations, questions and ideas though.

    1. You have this attachment system (which is an awesome addition). How about allow attachments to be weapons themselves that are fired with an alternate button? Sort of like secondary weapons in old FPS games. Just give the option to label a "weapon" as "primary fire" (uses left mouse button, RT) or "secondary fire" (uses an alternate button) and I think it would pretty much work (unless there are issues with your item type system that would require a completely different script for secondary fire). Just drop the shootable weapon stuff on an attachment, set it up and go!

    2. Do everything in 1 but gives guns an inventroy (or slot) like system that allows attachments to be changed at runtime. Switch between that grenade launcher attachment and shotgun attachment on the fly!

    3. Melee weapons really need access to more "movesets". What I mean by this is possibly have both an Use State(Sequential) (light attacks with Mouse left) and Use State (Non-Sequential) (heavy attacks with another button or buttons). The non-sequential would be for like alternate attacks and you might add in a modifier section so you could do (heavy attack + left = heavy left attack) , or (heavy attack + shift = lunge).

    Furthermore I would add an In Air animation option so characters can do special melee attacks when in the air (like a ground slam). This is actually a lot like the attachment weapon idea above as well (essentially its just adding a secondary attacks that are differentiated by button press)

    4. (this goes along with the other two) I personally think states need to have button fields that let the dev assign the button to that state. Like the Melee example above, the "state" under "Use States(either) would have a drop down to allow you to select exactly what button (or buttons) should fire this state. Put it under Name and have a lot of options.

    Maybe just add Input Name onto the weapon On Use States like you do for abilities? (I assume that is how you set inputs for abilities anyways)

    I still haven't figured out where you define your buttons (As in your if(input.getbutton("X") stuff) so I am not sure how hard the implementation of 3 would be.

    for the drop down array you could have bools maybe.

    Ex.
    public bool XY = false; (bool shiftAttack, bool leftAttack, etc)

    if (Input.Getbutton("X") && Input.Getbutton("Y") XY=true. ///Where XY would be one of the drop down fields for a double press (could be shift + Mouse 2, left + mouse 2, etc)

    Anyways, just some stuff I noticed.
     
    Last edited: Jan 18, 2016
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    That's great to hear! Yeah I really like the way that the controller is setup and the script-based animation system has been working out really well.

    You have really good timing with those three ideas. The past few updates have been focused on ability improvements and the next feature update will be focused on item improvements. The item system hasn't had any major updates recently and it's time to change that. We are going to be putting out a minor improvements/bugfix release this week but the update following that will be the item system update. All of your ideas sound like something that I want to include in the update.
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    The button names are defined in Constants.cs, but it wouldn't be hard to expose a field which allows you to use a custom name. This is what the ability system does.
     
  31. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    That's awesome to hear! I added another idea in an edit that some people might find handy (the ability to change attachments at runtime). Not sure if you can do that right now or not.

    Yeah, after I figured out Name meant Upper Body Animations and Lower State Name meant lower(or full) body animations my mind opened up to all the possibilities. I have been doing mecanim "trees" the long way since Unity 4 came out. Your method is a massive improvement.

    Question: If I want to have "transition" animations I just need to make them the first thing in the state right?

    So it would go Entry -> Transition animation -> repeating animation?

    For example

    Entry ---> Grab ledge ---> Hang.

    Thanks, hadn't even looked at that script yet. I'll check it out.
     
    Last edited: Jan 18, 2016
  32. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    That is correct


    This is from your first post but I wanted to add to it:
    Instead of just having an air animation, I'd like to make it generic enough so you can play a specific animation for whatever state the character is in. Want to play an attack animation while hanging on a pipe or while swimming? No problem.

    We obviously won't be able to provide all of the animations for every specific scenario but the goal is to allow the framework to be able to handle it without you having to make any script changes. We'll see how successful I am at this :)
     
  33. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    That makes sense. So you would like broadcast the state a character is in and allow weapons or abilities to use that to decide what animation to play?

    I wouldn't expect you to provide all the animations :p. We have an animator for that reason. The framework stuff, yeah that is what is important.
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    You make it sound so easy ;) But yes - the goal is to have the item system be more aware of the ability system so you can play custom item animations based on the ability state.
     
  35. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    Ok, one last observation for today.

    In one of my old TPS controllers I added in the ability to set a horizontal torso look radius. Basically this was a point(in degrees) in which the body would turn to face the direction the character was aiming.

    For example (-15/15): While Idle the characters upper torso could rotate 15 degrees (in either direction) before the rest of the body actually turned. I based it loosely on how the AngryBots character works (Smite works this way, as well as Saints Row).

    The thing is, if you added this you would need the option to negate it while moving (really only works well when a character is in an idle state).

    It has the added benefit of getting rid of the weird floaty circles that plague a lot of third person controllers (including this one). Add in a good animation and it almost looks like you are using root motion turning (which is another option for idle turning as well).. For a top down controller it is pretty awesome too (Think Lara Croft and the Guardian of Light).
     
    Last edited: Jan 18, 2016
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Just so I'm understanding, when you have the combat or top down movement type selected you want to be able to specify a number of degrees that the base character Transform will not rotate, and IK should rotate the upper body instead? If that's the case it seems like a quick addition so I can get it in the update going out this week. I'll take a closer look at the AngryBots demo now.

    Can you describe floaty circles a bit more? :)

    Edit: I added this as an option to the RigidbodyCharacterController - it'll be in the version going out this week!
     
    Last edited: Jan 19, 2016
  37. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    Yes you are 100% correct.


    When idle start turning in circles while aiming (not zooming). Look at the characters feet, if an animation isn't playing then it looks like the character is turning in circles while floating a bit above the ground. That's what I mean by floaty circles :p.

    Its noticeable when games don't have an idle turn animation (you would be surprised how many don't have this animation).
     
  38. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I have an issue with "knock back" when I run into something. I think it happens on things that are sticking out awkwardly. It knocks the player back, and sometimes, through walls. I turned up the mass on the rigid body, but that doesn't seem to help. It's currently 100, should I go higher?

    edit: did some testing. Changing from mesh collider to a primitive collider (box, capsule) seems to eliminate it. But sometimes, that won't really be possible and I'll need a mesh collider.
     
    Last edited: Jan 19, 2016
  39. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    I see what you mean now - yes, this new threshold should work well!

    That sounds like Unity's physics pushing it back. Try to set a physic material on the object with a maximum amount of friction to see if that prevent the character from moving back.
     
  40. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Made things worse! Now it flings me even further! Only happens on objects with little bit sticking out like a pipe with a pressure wheel on it. For now, I'll stick with a primitive collider.
     
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    If you send me a PM with the object I can take a closer look at it to see if there's anything that I can do on the character controller side of things.
     
  42. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Sent.
     
  43. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    What's the best way to override your IK for the arm with the pistol? I'd like to set it up in an outside script if possible. I'm trying to keep edits in your scripts to as few as possible so I can easily update.
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    If you change the private methods to protected virtual you can subclass the CharacterIK class. I'll do the same for PositionLowerBody, LookAtTarget, PositionHands, RotateDominantHand, and RotateNonDominantHand so you won't have to do it every time.
     
    drewradley likes this.
  45. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    UFPS Standard Logo 244x92.png


    I'm really excited to finally be able to share the following news:

    Opsive will take over as the official publisher of the Unity middleware software UFPS : Ultimate FPS and related products. VisionPunk, the team behind UFPS, will continue working with Opsive on the planned UFPS releases (1.6, 1.7 and Multiplayer 1.0). VisionPunk will also contribute to the design of UFPS 2, to be tightly integrated with the Opsive family of Unity assets including Third Person Controller and Behavior Designer. VisionPunk will remain an independent game developer.

    Justin Mosiman and Sarah Watson of Opsive says:
    Calle Lundgren of VisionPunk says:
    So, what does this all mean? Not much in the short term. Development for our next asset, the Deathmatch Kit, is going strong and we expect to have this asset released within a couple of months. The Deathmatch Kit will use both Behavior Designer and the Third Person Controller to create a FFA or team-based deathmatch game. We will also be doing regular updates to our existing assets. This acquisition will actually help speed up asset development because we will be able to hire a third person (get in contact with us if you're interested!)

    Further down the road UFPS 2 development will begin and it will contain tight integration with the Third Person Controller. UFPS is a very mature asset and I am extremely excited to see the results of combining the best parts from both UFPS and the Third Person Controller.

     
    Last edited: Jan 20, 2016
    Tinjaw, redjon29, nosyrbllewe and 6 others like this.
  46. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    Hey there question. I am using third person controller with inventory system pro, and also uma. The problem I am seeing is that third person controller hides the mouse cursor, and when you open an inventory pro window there is no mouse cursor to interact with it.

    is there a script included to show cursor, and / or freeze input to third person controller after an input button is pressed (say I for inventory, C for character, etc), or while one of those windows is open?


    Thanks
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    You can completely prevent the cursor from being disabled by disabling "Disable Cursor" on the Unity Input component. You can also show the cursor by calling the OnAllowGameplayInput event. It should already be taken care of for you though with the Inventory Pro integration. Using the Inventory Pro sample scene when I pressed I to bring up the inventory the cursor was freed, and when the inventory window was closed the cursor was locked again.
     
  48. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214

    the demo scene included with inv pro for UMA is most definitely not set up like that. and also why would it affect third person controller? On my scene, I always have a mouse cursor despite pressing I or R or C, it is always there and I can always control the character.

    unless you have a scene for integration with inv pro I'm not sure what scene you mean besides the included uma scene, which is not made for third person controller.
     
  49. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    ah I see on your site there is another download for inv pro integration. my bad.
     
  50. rpg_gamer

    rpg_gamer

    Joined:
    Nov 28, 2012
    Posts:
    214
    still can't quite get it to work on the uma character. It works on the demo scene you included, but that is not a uma character. when I add inventory controller bridge to my uma character, and open an inventory window... I still get no cursor, and I can still control the uma character
     
Thread Status:
Not open for further replies.