1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

UE3 - UDK Stamina system?

Discussion in 'Programming' started by BeefyPoopStain, Mar 23, 2011.

  1. BeefyPoopStain

    BeefyPoopStain New Member

    Joined:
    Mar 23, 2011
    Messages:
    2
    Likes Received:
    0
    My friend and I are developing a zombie-survival game with UDK, and we're working on implementing some melee weapons. We would like for the player to lose some stamina when swinging a baseball bat, but we're not quite sure where that would be handled programmatically - we were thinking probably the InventoryManager class, since that interfaces with a pawn and handles the firing functions. I'm just not sure how to go about adding the functionality, and any help or a nudge in the right direction would be much appreciated.
     
  2. Angel_Mapper

    Angel_Mapper Goooooooats

    Joined:
    Jun 17, 2001
    Messages:
    3,532
    Likes Received:
    3
    That would probably be better in the PlayerController class. As an example, you could have a float Stamina there which defaults to 1. Every Tick it checks to see if it's less than 1 and increases it by doing:
    Code:
    Stamina += RecoveryRate * DeltaTime;
    RecoveryRate is a var you would define.

    Then using:
    Code:
    FMin(Stamina, 1.0);
    To make sure it doesn't go over 1. Then as the player uses their melee weapon it would decrease Stamina by that melee weapon's StaminaReduction (a var you would add to your melee weapon class) by doing something like:
    Code:
    Stamina -= MyMeleeWeaponClass(Pawn.Weapon).StaminaReduction;
    MyMeleeWeaponClass would be an abstract class all your melee weapons would subclass from.

    Then, before you allow the player to use a melee attack you would check to make sure Stamina was greater than a certain amount (0.0 for example).

    Hope this helps!
     
    Last edited: Mar 23, 2011
  3. BeefyPoopStain

    BeefyPoopStain New Member

    Joined:
    Mar 23, 2011
    Messages:
    2
    Likes Received:
    0
    That does help a lot, but I'm still wondering how the firing functions are accessible in the PlayerController class. There's not a lot of documentation that we could find concerning appending functionality onto the firing procedures, and the reason we were looking at the InvManager class is because it seemed to sort of bridge the gap between the weapon and the pawn and handle the firing functions.
     
  4. Angel_Mapper

    Angel_Mapper Goooooooats

    Joined:
    Jun 17, 2001
    Messages:
    3,532
    Likes Received:
    3
    You could put this in the Pawn class instead and work directly in the StartFire and StartAltFire functions there.

    As for documentation, there is no better documentation than the source files themselves. I'd recommend reading through Object.uc, Actor.uc, GameInfo.uc and the Controller and Pawn classes to get an idea of the functionality that's available to you. Literally just sit down and read them.
     
    Last edited: Mar 23, 2011

Share This Page