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

    jessejarvis

    Joined:
    Aug 9, 2013
    Posts:
    303
    I am but this happened on a previous version too, however I will try IsKinematic as suggested in that post, that seems like it would work.

    Edit: Did not work. However it's possibly related but I am getting this error too:

    Code (CSharp):
    1. Assertion failed: Transform has SetIsDispatchInterested present when destroying the hierarchy. Systems must deregister themselves in Deactivate.
    2. Assertion failed: Transform has SetIsHierarchyDispatchInterested present when destroying the hierarchy. Systems must deregister themselves in Deactivate.
    Edit 2: Nvm, I see this is a 1.3.4 issue, I just need to update. Thanks.

    Edit 3: I confirmed that it is the isKinematic. I temporarily fixed it with the following:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class AnnoyingWorkaround : MonoBehaviour {
    6.  
    7.     private Rigidbody _rigidBody;
    8.  
    9.     // Use this for initialization
    10.     void Start () {
    11.         _rigidBody = GetComponent<Rigidbody>();
    12.     }
    13.    
    14.     // Update is called once per frame
    15.     void Update () {
    16.         if (!_rigidBody)
    17.             return;
    18.  
    19.         if (!_rigidBody.isKinematic)
    20.             _rigidBody.isKinematic = true;
    21.  
    22.     }
    23. }
    However as I said it's fixed in the newer ones. You could also just comment out 2 lines in the source as well, this was just to test before updating.
     
    Last edited: Feb 5, 2018
    opsive likes this.
  2. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    i'm trying to look into this but is there any way to zoom in when aiming? like a sniper gun for instance. I'm not sure whether it's already there but it would be great to move from third view to something closer when aiming.
     
  3. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Yes, on the Zoom camera state you can set a new offset which will allow you to change the camera's location:

    http://opsive.com/assets/ThirdPersonController/documentation.php?id=127

    It's under the Movement Options.
     
  4. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I'm having tons of performance problems with this so far. I work on mobile and even on PC when I instantiate one of my characters there is a 2 to 3 seconds stall. The profiler says it's Inventory.Initialize() -> AnimatorMonitor.Initialize() -> AnimatorMonitor.PlayDefaultStates() -> Animators.Update() -> Animators.FireAnimationEventsAndBehaviours() -> Animator.FireAnimationEvents
    That thing is taking 92% of my cpu, and I have a 4.0ghz 8 cpu machine. The whole thing just stalls. On mobile you can basically go take a nap until it recovers.

    Now, try to play on network mode, when any other person spawns a new instance, the whole thing stalls. So every time someone joins, everyone gets locked for 2 to 3 seconds.

    Any suggestions? It makes it unusable even on PC.
     
    Last edited: Feb 12, 2018
  5. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    That seems unusually high.

    Indicates that the bottleneck is happening when the animation events are fired. How many animation events do you have occurring within the idle state? Does the same issue occur across multiple unity versions?
     
  6. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    No idea. All I did was create the character using the included character builder. So it has your default animations and settings. I'm using 2017.3.1
     
  7. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Are you able to reproduce it within a demo scene from a fresh project? I just tried it and wasn't able to reproduce the long load time. You can also see what events are sent by placing a Debug.Log in AnimatorMonitor.ExecuteEvent.
     
  8. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I have a question about the Ladder climbing. I would like it to be fully automatic: it should climb when it arrives to a ladder and exit it... it doesn't matter what direction you decide to go up or down. So I run to the ladder, automatically go up (it seems to work already) but then decide that I can to go down, so i move down... it won't exit the ladder even when set on "automatic". If I set start/end on automatic it seems to fail a lot.

    Any ideas?

    I also have problems where sometimes I get stuck in a ladder without going up. It just stays there like in between animation states.

    The other problem is about ladder sizes. If I want a ladder that it's 10 timers taller than the included onces, i see no way to do so. If i scale the ladder it looks messed up and all collisions fails. If I don't scale them I have to attach tons of them together and it's also a problem. How do you go about having long ladders?
     
  9. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Ok i think i found the bug with the ladders. Make a long ladder, any. No scaling, just a long Box Collider for testing. You'll see they don't work. The problem is that it seems to be using Top Mount Complete Offset (y value) and Unusable Top Rungs in some kind of combination so that it won't either arrive to the top or fully to the bottom. If you fix one, it will break the other. It seems to only work fine with the example ladders included in the demos. Any other larger size will fail.
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    The ladder should be able to be an arbitrary length. On the back of the clean scene there is this ladder which is much taller:

    ladder.PNG

    Have you seen this page which explains how to setup a ladder? It might also help to compare your ladder to that taller latter in the clean scene
     
  11. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Ok, i found how to reproduce my mess up on moving up/down the ladders with the sample scene.
    Open the Clean Scene demo. Modify the Climb property on Dom_Shooter character to Start Type = Automatic. Stop Type = Manual.

    This should make it go up/down the ladder automatically without pressing F.

    Now for the fun part. Hit play. Pick up the gun on the floor. This is important. It seems to be related to some animation because it only happens with that gun. Now you should have your double gun hands... walk towards any ladder. It will automatically go up. Now go down the ladder till the end. You are stuck. You can't move up or down any more. Driving me crazy on my game.

    Already 2 days trying to figure out what's wrong.
     
  12. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
  13. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    The reason for that is because of the automatic start type. When the ability ends it then tries to start again because the character is in front of the ladder. In terms of a fix, I would modify the Climb.CanStartAbility method so that it only returns true either after a cooling off period or the forward input vector is 1 (m_Controller.InputVector.z).

    It only may be an issue with the pistols because the colliders are getting in the way of the destination. This causes the character to continuously walk but the character can't because of the collision.
     
    Last edited: Feb 14, 2018
  14. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    well, even doing that trick fails sometimes (sometimes it gets stuck when trying to go up and it won't unlock). But i have so many troubles with it. For instance, check this on my game right now using the same settings. The animations seem wrong.
    http://www.youtube.com/watch?v=nUd_u-nWVPg

    I'm printing out ton of stuff on the animator to see where it's going.
    When i'm moving the base animation (layer 0) is on state of Movement.
    Layer 1 (the upper body) and higher are into the Aim animation while I'm moving. All good.

    Then when I hit the ladder, the order goes:
    a) Layer 1 and higher = Unequip (i guess to hide the weapon)
    b) Base goes to Movement and Layer 1 to Aim (erm... not sure why it would do this)
    c) Base to Movement and Layer 1 to Equip (uh?)
    d) Base finally states Climb.Ladder Bottom Mount, Layer 1 = Equip
    e) Base on Climb.Ladder Buttom Mount, Layer 1 = Aim (uh?) and all higher layers (arms/hands) on idle.
    And that's how it stays while climbing the ladder.
    It will just flip between base = Climb.Ladder Left Up/Right Up, Layer = Aim and all arms and hands on Idle.
    I would guess that those last have to be on some Climb state or something to pull up the ladder.

    If on the character controller, under Item I don't set the "always aiming" option, it will animate correctly but then my character won't be always aiming while running. And I want it always aiming while moving around.
     
    Last edited: Feb 14, 2018
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    I'm trying to reproduce it so I can take a closer look. Within Climb.CanStartAbility I added the following:

    Code (csharp):
    1.  
    2.         public override bool CanStartAbility()
    3.         {
    4.             if (m_Controller.InputVector.z < 1) {
    5.                 return false;
    6.             }
    7.  
    And then I didn't get stuck at all with an automatic start type:

    https://streamable.com/n5mls

    In the log it outputs "started" when the climb ability starts.
     
  16. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Ok, i fixed it. The problem happens to be a combination of certain animations and setting it to "always aim".
    Here is my fix, on Climb.cs and this code will make you move up/down the ladder automatically (If your start ability is set to automatic). It will also work on joysticks and touch screens where you don't get a straight forward 1/-1 for input. It will approximate it to 80% forward/backward.

    Code (CSharp):
    1.  
    2. private bool wasAiming = false;
    3.         // returns whether two values are approximately equal. In this case a 0.2 difference from the numbers
    4.         private static bool Approx(float a, float b)
    5.         {
    6.                 if (a >= b - 0.2f && a <= b + 0.2f)
    7.                     return true;
    8.                 else
    9.                     return false;
    10.         }
    11.         /// <summary>
    12.         /// Can the ability be started?
    13.         /// </summary>
    14.         /// <returns>True if the ability can be started.</returns>
    15.         public override bool CanStartAbility()
    16.         {
    17.             // The character can climb if the character is on the ground and a climbable object is near.
    18.             if (m_Controller.Grounded &&
    19.                 ((Approx(m_Controller.InputVector.z,1f) && Physics.SphereCast(m_Transform.position + m_Transform.up * 0.1f - m_Transform.forward * m_SearchRadius, m_SearchRadius, m_Transform.forward, out m_RaycastHit, m_StartClimbMaxDistance + m_SearchRadius, m_ClimbableLayer.value, QueryTriggerInteraction.Ignore))
    20.                 ||
    21.                 (Approx(m_Controller.InputVector.z,-1f) && Physics.SphereCast(m_Transform.position + m_Transform.up * 0.1f - ((-m_Transform.forward) * m_SearchRadius), m_SearchRadius, -m_Transform.forward, out m_RaycastHit, m_StartClimbMaxDistance + m_SearchRadius, m_ClimbableLayer.value, QueryTriggerInteraction.Ignore))))
    22.             {
    23.                 // The character must be mostly looking at the climbable object and moving towards it or on the back and moving backwards.
    24.                 if ((Approx(m_Controller.InputVector.z, 1f) && Vector3.Angle(-m_RaycastHit.normal, m_Transform.forward) < m_StartClimbMaxAngle) || (Approx(m_Controller.InputVector.z, -1f) && Vector3.Angle(-m_RaycastHit.normal, -m_Transform.forward) < m_StartClimbMaxAngle))
    25.                 {
    26.                     if ((m_ClimbableObject = Utility.GetComponentForType<ClimbableObject>((m_ClimbableTransform = m_RaycastHit.transform).gameObject)) != null)
    27.                     {
    28.                         this.wasAiming = m_Controller.AlwaysAim;
    29.                         m_Controller.AlwaysAim = false;
    30.                         m_ClimbableObject.Mount(m_Transform);
    31.                         if (Utility.GetComponentForType<BoxCollider>(m_ClimbableObject.gameObject) != null)
    32.                         {
    33.                             m_StartNormal = m_ClimbableTransform.forward * (Mathf.Sign(m_ClimbableTransform.InverseTransformPoint(m_Transform.position).z) == -1 ? 1 : -1);
    34.                             m_ClimbNormal = m_ClimbableTransform.forward * (m_ClimbableObject.CanReverseMount && Mathf.Sign(m_ClimbableTransform.InverseTransformPoint(m_Transform.position).z) == -1 ? 1 : -1);
    35.                             m_MountStartPosition = m_ClimbableObject.MountPosition(false);
    36.                         }
    37.                         else
    38.                         {
    39.                             m_ClimbNormal = m_StartNormal = -m_RaycastHit.normal;
    40.                             m_StartNormal.y = 0;
    41.                             m_StartNormal.Normalize();
    42.                             // If there is no BoxCollider then the start position is based off of the raycast hit position.
    43.                             m_MountStartPosition = m_RaycastHit.point + Quaternion.LookRotation(-m_StartNormal) * m_ClimbableObject.MountPosition(true);
    44.                         }
    45.                         return true;
    46.                     }
    47.                 }
    48.             }
    49.             return false;
    50.         }
    51.  
    Then on the AbilityStopped method on the same file just add:
    m_Controller.AlwaysAim = this.wasAiming;

    This way even if you had set the controller to Always Aiming, it will not break the animations or get stuck. I think the ability already has an option to not allow for aiming but for some reason the animator gets confused unless I hard code it this way.
     
  17. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Now i just want to fix that weird rotation when moving backwards to go down the ladder. Right now it will automatically first rotate it the opposite direction and then rotate it back to the ladder. Very annoying. I can't find where in the code it does that so I can let it not fully rotate when you just went up the ladder, hit backwards and go down again.
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Thanks for posting your solution - I'll take a look at incorporating it into the next version.

    Are you able to reproduce that within the clean scene? It sounds like something within Climb.UpdateRotation is causing the character to flip.
     
  19. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    yeah it also happens on the demo. If you walk backwards and press F (or just set it to automatic), you'll see the character will rotate completely although you are already on the correct position to go down the ladder. You can see it on the first video I posted, when I came back down:

    At time 1:00, i finished going up (moving forward), then I pressed backwards and it rotated and sat down like that although it was unneeded.

    I checked the UpdateRotation method but it doesn't seem to be there. It seems there it's already mounted so it has to happen before it seems (still trying to understand all your code)
     
    Last edited: Feb 14, 2018
  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Ah, that relates to the Top Mount animation. Within Climb.GetDestinationState when the ClimbID is MountTop the character plays a mounting animation that assumes you are looking at the ladder. With root motion the character does the movements and then once the mount is in place UpdateRotation takes over and ensures the character is facing the correct direction. It looks like we need to create a new mounting animation for that case.
     
  21. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I think it can be the same than the unmounts top animation but played on reverse order. Is there an easy way to do that so I don't need to wait for an update?
     
  22. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    ok another one... I can't change the rung sizes much or everything goes nuts. Using the included demo scene. Just change the long ladder as explained on the video.
    http://www.youtube.com/watch?v=wXhxfEDQYVY

    This one is problematic because some of my ladders got bigger spaces in between and i can't get them to match the animation.
     
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Here's how I would approach it:

    Within Climb.InPosition you'd set the ClimbID to a new ID named MountTopBackwards. You can detect if the character should mount backwards based on the rotation compared to the ladder.

    After that you'll want to return a new animation name for the MountTopBackwards id. This is set within GetDestinationState and you'll need to have a corresponding state within the animator (it can be the dismount animation backwards).
    It looks like the offset values need to also be adjusted - notice at the point the character dismounts there's that green gizmo and that's where the dismount animation starts. The ability doesn't use IK so for different run separation lengths you'll need an animation that matches it.
     
  24. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    The problem with the rung size is that the code assumes you move one rung up or down. But the code moves up/down not a rung size but a given force. So they get out of sync and it's very obvious on large values. If your ladder is 10 meters high and you set rung size of 1 meter... it will divide it into 10 portions. Then when it moves up 10 times, it will stop the animation. It doesn't "arrive" to the end location, it just calculates you moved 10 times. The problem is that you don't move up 10 times the rung size, you moved up 10 times whatever the character controller told it, which may be 5 inches. So suddenly in the middle of the ladder you come out. And it does the same coming down. In short, the whole thing is wrongly calculated.

    To be more specific, in Climb.cs UpdateMovement you have:
    relativeForce.y = Mathf.Min(Mathf.Abs(relativeForce.y), Mathf.Abs(m_ClimbableObject.RungSeparation - m_VerticalDistance)) * Mathf.Sign(relativeForce.y);
    m_VerticalDistance += Mathf.Abs(relativeForce.y);


    The climb.cs and climbableobject.cs has to be changed. The options are, to either move vertically by the RungSeparation always or to keep track of the real vertical moment and use that on climbableobject.cs to calculate the begin/end of each animation instead of using the RungIndex which can be completely out of sync with the real animation.
     
    Last edited: Feb 15, 2018
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    The climb ability use root motion so the animations will generally match the rung size and this isn't a problem. The reason I did this was because it looks the most realistic and you don't just have the character moving up/down according to a predefined curve. You're right though in that when you are prototyping it doesn't work very well, maybe to modify it the dismount should be based off of location rather than rung index? Within ClimbableObject.CanDismount?
     
  26. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    yeah, and then i would remove the rung size because it's almost untouchable. It will just lead to this kind of problem. But I think it needs to be revisited. If for instance your ladder is inside a scaled object (a house or whatever) things will also break because many of the calculations do not take into consideration local scaling. Also if you have a parent with a rigidbody, things won't work either because the transform will point to the parent, not the collider size. I'm basically rewriting 90% of it because it seems to only work fine on the demo.
     
  27. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Lastly on the demo, the moving platform code seems wrong too. Try to jump into the one that it's not moving up and down but that crosses around the area. I always slide out of it.
     
  28. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    One of the things that we have planned is expanding on the climb ability to be much more generic allowing you to climb any shaped objects. This will likely lead the climb ability being completely rewritten in order to support these new use cases and I'll also account for scaling.

    Moving platforms are tricky with rigidbodies. This has been fixed with version 2 because a custom kinematic controller is now being used instead of a Rigidbody (or the Unity CharacterController component). Moving platforms now behave as well as they do in UFPS (and then some). We should have the first beta of version 2 out next month and are hoping for a late spring release. This page has a FAQ on v2.
     
    Last edited: Feb 15, 2018
  29. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    yeah but i can't wait for v2 and i purchased the asset thinking that the stuff included on the demo would work. There has to be a way to fix that moving platform, my game is full of them and it was one of the main selling points for TPC
     
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    I've sent you a PM :)
     
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Our original goal for v2 was to multiplayer addon at the same time as the base v2 release. It doesn't look like this is going to be possible as a couple of Animator Controller bugs have prevented our progress. The latest issue that I am hitting relates to reverting an animator controller state and how it isn't transitioning correctly after being reverted. Reverting the animator state is necessary for server reconciliation and client side prediction using an authoritative server (such as the unet implementation).

    I'm not sure how much Unity devs look at the this but if you can vote for this issue in the Issue Tracker that'd be great! Until this bug is fixed we won't be able to release the multiplayer addon.

    https://issuetracker.unity3d.com/issues/animation-animator-transition-does-not-get-interrupted

    Thank you!
     
  32. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    how can we make an ability that can hold the weapon and move the hands freely?
    I've created a swim animation that I can set on the base layer. The animation is fine and I've calculated it on a way that the guy can hold the hand (and weapon) outside the water. But no matter what I do with the swim.cs file, the animation always plays with the character aiming. So the legs are moving with my animation but the guy is holding the weapon aiming forward (not my animation). I've tried to do a aim=false, alwaysaim=false and he still holds the gun aiming ignoring my swimming animation.

    My whole animation is on the base layer. I've tried setting it up also on the upper layer but nothing helps. I don't want to remove the weapon from the hand since I want to swim while holding it, I just don't want it to be aiming.
     
    Last edited: Feb 19, 2018
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    If I'm following correctly when the swim ability starts you have always aim on and you want to disable it when the swim ability starts, correct? Calling RigidbodyCharacterController.AlwaysAim will disable it. You may need to call AnimatorMonitor.DetermineStates again so the controller checks for what states should be running.
     
  34. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Well, swim was an example because I'm replacing it's animation. When I do AlwaysAim = false, it doesn't work. The guy is still aiming or holding the weapon using the idle animation state. All I want is to hold the weapon and do my swimming animation (my hands should be moving on a swimming mode), but at the same time my weapon should be visible.

    Without replacing the existing animation, how can i do that just modifying the swim.cs? Meaning, the guy swims with the weapon on hand and the hands swimming animation. Not aiming. The weapon will get wet, and I don't care.
     
  35. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    To make it more clear. Let's imagine I have an animation that my character jumps with weapon in hand shooting at the sky.
    How can i make an ability that would animate that? If I disable aiming on the ability, the weapon and hands will go into the holding idle weapon state. My character will jump but my character won't be shooting at the sky, which is what I want.
    I've tried copy the animation into the base and upper layer, but it seems to be ignored. The hand will not go up and shoot.
     
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    It sounds like you want to use Ability.CanHaveItemEquipped. If this returns true then the item will not be unequipped when the ability starts. If you want to use the item as well you'll want to make sure CanUseItem and CanInteractItem also return true.
     
  37. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Those are already set to True. It's actually the default values for any ability. I've tried with false on some, with true, with changing checkbox all over. Nothing works.

     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    It's tough to say what's going on without debugging it on my local machine. If you enable "Debug State Changes" on the Animator Monitor it should help with tracking down exactly what is going wrong. If you send me a repro scene I can also take a closer look at it.
     
  39. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Ok, i'm making some progress. I've got an exception at Ability.cs method StartAbility line around 177
    // m_EquipItem may already be true if the ability set it ahead of time.
    if (m_EquipItem || CanHaveItemEquipped() || m_ItemEquipped.Get() == false) {

    here it says m_ItemEquipped is null. Where does that variable get initialized? I can't find it anywhere since you have those weird reflection system on figuring it out the properties. Also, why would that be null? I'm clearly equipping my weapon.
     
  40. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    so I've modified your code to display the error and here is the issue:


    Code (CSharp):
    1.         public virtual void StartAbility()
    2.         {
    3.             m_Active = true;
    4.             EventHandler.ExecuteEvent<Ability>(m_GameObject, "OnAbilityStart", this);
    5.  
    6.             // m_EquipItem may already be true if the ability set it ahead of time.
    7.             if (m_EquipItem || CanHaveItemEquipped() || (m_ItemEquipped != null && m_ItemEquipped.Get() == false)) {
    8.                 Debug.LogError("if we pass through here, the arms won't animate");
    9.                 AbilityStarted();
    10.             } else {
    11.                 Debug.LogError("if we pass through here, the arms animate");
    12.                 m_EquipItem = true;
    13.                 EventHandler.RegisterEvent(m_GameObject, "OnAnimatorItemUnequipped", AbilityStarted);
    14.                 EventHandler.ExecuteEvent(m_GameObject, "OnAbilityToggleEquippedItem");
    15.             }
    16.         }
    If you pass through the first "if", the hands will never ever get animated. If I pass through the "else" the animation works just fine. My character dance but my Pistol gets removed.

    1) Issue #1, no idea where m_ItemEquipped is defined because I get a null in there. I had to add that if !=null to stop the exception. I printed a message there to see when it is defined and when it is not. SpeedAbility for instance has m_ItemEquipped defined, but other abilities have it set to null. The refraction code is a nightmare because there is no way for me to know when it is called and whether it is not called. So I'm trying to find out when m_ItemEquipped gets lost and set to null in the middle of the code but so far no luck.

    2) You said all I needed to do was tell it to have the item equipped and usable. From that code it seems it's actually the opposite. You have to have your item Unequipped for the Ability to animate your arms. This is a big problem since I want to hold my weapon.

    I found the chunk of the animator code that deals with that, and it seems that weapons need to have some extension with higher priority to be able to be held while dancing. I see nowhere on the doc any of that info, neither an example. How can I make my pistol be able to keep on my hand while I dance? The feeling i'm getting is that you haven't done it before because doing what you told me would not achieve that result.
     
    Last edited: Feb 20, 2018
  41. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Take a look at this for how that system works:

    http://opsive.com/assets/ThirdPersonController/documentation.php?id=44

    It doesn't look like the initialize method is being called before that line is called.

    (Not directly related but the reflection system has been removed for v2 and only interfaces are used).

    The ability will start immediately if the item can be equipped. The else section of that block will toggle the item equip if the item can't be equipped.

    GetDesinationState determines what state is returned. With swimming only the base and upper body layer is used:

    Code (csharp):
    1.  
    2.             if (layer == m_AnimatorMonitor.BaseLayerIndex || layer == m_AnimatorMonitor.UpperLayerIndex) {
    3.  
    If you haven't seen it I recommend taking a look at this video for how abilities work:

     
  42. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    At this point I think I know how ability works... i mean, I've read 90% of the whole system code looking on how to fix bugs. I've created a bunch of abilities already. The problem here is how to create one that can hold the weapon on the hand!
    For instance, on that video, how do you make that dude walk that thing while holding the weapon with the arm extended exactly like it is on that animation. It seems literally impossible. It seems it can be done with a shootableweaponextension modification or something like that from what i saw on the code, but there is no documentation or anything that would explain it. Can you make that guy on the last video walk while holding a pistol on the right hand, arms extended so he doesn't fall? That's the problem. It seems it cannot be done at all, he has to always hide the weapon or if he doesn't, the arms won't extend and he will be aiming.
     
  43. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    The HeightChange ability is great example of this. In it the character can continue to hold the weapon while the ability is active. At the start of HeightChange.GetDestinationState it has:

    Code (csharp):
    1.  
    2.             // The ability only affects the base, upper, and any layers that the item specifies.
    3.             if (layer != m_AnimatorMonitor.BaseLayerIndex && layer != m_AnimatorMonitor.UpperLayerIndex && !m_AnimatorMonitor.ItemUsesAbilityLayer(this, layer)) {
    4.                 return string.Empty;
    5.             }
    6.  
    This check will determine if the layer is either the base, upper, or a layer that is specifically setup for the HeightChange ability using the item animation options. The item animation options allow you to define a specific animation state that the animator should be in while an ability is playing with an item.

    If I turn on Debug State Changes and crouch with the assault rifle I'll get the following:

    Notice the animator is transitioning to a specific assault rifle animation for the crouching state. This is because of the item animation options:

    ItemAnimation.PNG

    The Jump and Fall abilities can also still hold the item while the ability is active. These abilities don't have a specific animation setup for them though so they aren't as good of an example.

    Hopefully that helps!
     
  44. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Error, trying to build for UWP
    Assets\Third Person Controller\Scripts\Utility\Utility.cs(76,42): error CS0103: The name 'GetStorageFileAssemblies' does not exist in the current context

    Missing assembly reference or something?
     
  45. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    That line can be removed - it was accidentally brought over from the Behavior Designer UWP support.

    Code (csharp):
    1.  
    2.                     s_LoadedAssemblies = new List<string>();
    3.                     var assemblies = AppDomain.CurrentDomain.GetAssemblies();
    4.  
     
  46. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @opsive ,

    Really looking forward to release of V2!

    Is there any link I can go to, to go see what new things and enhancements and core features are definitely going to be in V2?

    I've owned this amazing Asset for some time but I've noted that it's so damned good as the go-to TPC that other Asset authors are actually waiting for V2 before they build integrations!
     
  47. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    We're looking forward to getting it released :) We don't have the exact features listed yet but we do have a FAQ here. Our twitter account is probably the best source to see what we're currently working on.
     
    Duffer123 likes this.
  48. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @opsive ,

    Thanks. I will check out that link....
     
  49. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Building for uwp on SharedManager.cs this line
    using BindingFlags = Opsive.ThirdPersonController.BindingFlags;
    it says it can't find it.
     
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,128
    Good catch. That should be System.BindingFlags.
     
Thread Status:
Not open for further replies.