TryStartAbility Playmaker

Everknight

New member
So, I have been slowly learning how to use UCC, and I have a pretty good grasp of most of it, But I have a test AI Character that runs around and tries to shoot the player, But when he is within range he is not able to fire the weapon.

When he is within a certain distance of the player Playmaker uses a script that fires functions as needed. The one to fire the weapon is

Code:
  public void Awake()
    {
        
        m_Character = this.gameObject;
        m_CharacterLocomotion = GetComponent<UltimateCharacterLocomotion>();

    }
 
 
 public void UseWeapon()
    {
        

         ItemAbility useAbility = m_CharacterLocomotion.GetAbility<Use>();
         if (useAbility != null)
         {

            useAbility.StartAbility();

            
         }
        
      
    }

Looking at the documentation this is pretty similar to the as the written example, so I didn't expect much trouble figuring it out.

I have confirmed that the weapon is indeed equipped, it is not waiting for any animation events, and the state is not being updated in the animator, I'm not sure what else to look for at the moment.

any help would be appreciated

Thanks!
 
A few checks to make:

1. Where is UseWeapon being called from? Is it definitely getting called?
2. Is useAbility definitely being assigned properly (i.e. is the if statement definitely passing?) (You should assign useAbility in Start() instead anyway.)
3. Try having useAbility be of type Use instead of ItemAbility.
4. Instead of useAbility.StartAbility(), try m_CharacterLocomotion.TryStartAbility(useAbility)
 
Hi Andrew, I appreciate you taking the time to help me with this,

UseWapon is called via Playmaker, and it is for sure being called if I access the shootableweapon.fire() directly through the same method it does fire, but obviously not correct. I did go back and try using it as written in the documentation example.

I swapped Awake for Start, and went ahead and assigned Use Ability in

I added some debug statements throughout TryStart() ability and it was ultimately returning false, But the ability itself is never activating.


When useAbility is assigned it is returning Character.Abilities.Items.Use which is correct.

It feels like something is actively stopping the ability from starting, but I can't seem to figure out what that would be, as none of the settings for The Use Item ability itself have been changed for the AI character unless I've missed a step in setting an AI character with the character manager

I know it's redundant to post the code again, so I hope it isn't too annoying, but maybe there is something legitimately wrong here that I just don't recognize, It isn't a complicated set of functions.


Code:
public class AI_Functions : MonoBehaviour
{
    // Start is called before the first frame update

    public ShootableWeapon MyWeapon;
    [SerializeField] protected GameObject m_Character;
    [SerializeField] protected UltimateCharacterLocomotion m_CharacterLocomotion;
    [SerializeField] protected Use useAbility;
    public void Start()
    {
        // MyWeapon = this.GetComponent<ShootableWeapon>();
        m_Character = this.gameObject;
        m_CharacterLocomotion = this.GetComponent<UltimateCharacterLocomotion>();
        useAbility = m_CharacterLocomotion.GetAbility<Use>();
    }

    public void UseWeapon()
    {
       

         // Supposedly this is how it's supposed to be done, but for some reason the ability is refusing to actually fire, I will work with this more later provided i have time, or i recieve unsatisfacotory results
       
         if (useAbility != null)
         {
            Debug.Log(useAbility);
            m_CharacterLocomotion.TryStartAbility(useAbility);

           
         }
     
    }
}
 
Last edited:
I can't see any issues with your script. Does the agent character have another, higher-priority, ability active at the time of attempting to start the Use ability? Abilities that are higher up in the list are considered higher-priority and will block those lower in the list whilst active (with the exception of "concurrent" abilities). Also, where exactly were you logging that was returning false?
 
Have you seen the Playmaker integration? There is a use action within that package.
 
@Andrew CanStartAbility() was returning false, and TrStartAbility returns false unless I pass true for ignorecanstartcheck, I'll look at the list of abilities, but I'm fairly certain the only one to be used at the time is the Use ItemAbility, does the Use Ability under Abilities need to be available as well?

@Justin I was unaware there were any integrations with playmaker, I was under the impression there was simply compatibility.

However my goal is mostly to become fluent enough with the system to be able to use it consistently, so I would still like to find out what is ultimately causing the issue I have. I'm sure its simple But I will definitely take look and see if that works, that would be a nice alternative.
 
I used the Playmaker integration and found that the ability is still not working as intended, along with using the Start Stop Ability script in playmaker I used the is Ability active running every frame and it returns false,

the only enabled Item Abilities are Use, Reload, and Equip Unequip, which seem to function normally as the weapon is indeed equipped, Disabling this results in the weapon disappearing at runtime. As an added measure I have moved Use to the top of the Item Abilities list in case this was a priority issue, and the weapon still does not fire.

Normal abilities are Jump, Fall, Move Towards, NavMeshAgentMovement, SpeedChange, Height Change, and Item Equip Verifier.
 
I'm really at a loss here, is there anything by default that would block the use item ability from being activated?

because even then, when I pass true for the ability to not check if it can start the gun still doesn't fire. so I don't know what I'm doing wrong here.
 
If you set a breakpoint within TryStartAbility what is preventing the use ability from starting? Another ability could be stopping it within ShouldBlockAbilityStart.
 
Have you seen the Playmaker integration? There is a use action within that package.
Can you get a more detail on exactly where it's returning false?

Also does your Use item ability's Action ID match that of the agent's item? And is the agent's item set up properly with its ShootableWeapon components etc?
 
Top