Run States for weapons

MissBig

Member
Hi I have run states for weapons which work out great but I also have stamina so when it uses up the character walks which also works great but the problem I have if I don't have stamina left and I hit the shift key to still run the weapon still goes into the run state so how would I disable this from happening,
 

Attachments

  • Weapon state.PNG
    Weapon state.PNG
    12.5 KB · Views: 10
  • SpeedChangeAbility.PNG
    SpeedChangeAbility.PNG
    28.6 KB · Views: 10
  • AttributeManager.PNG
    AttributeManager.PNG
    23.4 KB · Views: 8
I would guess your run ability is active. The way I did mine was to stop the ability when the stamina was low and only allow it to restart in Can Start Ability if stamina >x.
 
I would guess your run ability is active. The way I did mine was to stop the ability when the stamina was low and only allow it to restart in Can Start Ability if stamina >x.

So the only way to do this is in a script then. Is there another way with using the states though, I don't script.
 
I'm still in this situation where I'm not sure the best route to take. When the stamina is 0 then the character won't be able to run, but anything above 0 and the speed ability can start, so you get this On-Again-Off-Again situation.
 
I make the player wait until 100% to use stamina again. Penalty for hitting 0 is not being able to run for 5 seconds.
 
C#:
[DefaultInputName("Change Speeds")]
    [DefaultStartType(AbilityStartType.ButtonDownContinuous)]
    [DefaultStopType(AbilityStopType.ButtonUp)]
    public class Sprint : SpeedChange
    {  
        // Disable sprint when jumping or falling.
        public override bool IsConcurrent { get { return false; } }

        public override bool CanStartAbility()
        {              
            // Require the stamina to be at least 20
            m_AttributeModifier.ValueChange = -20;
            if (!m_AttributeModifier.IsValid())
            {
                m_AttributeModifier.ValueChange = 0;
                return false;
            }
            m_AttributeModifier.ValueChange = 0;
            return base.CanStartAbility();
        }      
     
    }

I subclass the SpeedChange, and this works fine with my purpose.
 
Top