View Full Version : UE3 - UDK Stamina system?
23rd Mar 2011, 12:57 PM
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.
23rd Mar 2011, 02:22 PM
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:
Stamina += RecoveryRate * DeltaTime;
RecoveryRate is a var you would define.
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:
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!
23rd Mar 2011, 02:47 PM
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.
23rd Mar 2011, 04:07 PM
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.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.