Function overriding
In addition to variables, functions declared in parent classes are also inherited by their children. This lets us change behavior that goes beyond simple variable changes. For example, two pickups under Inventory | UTInventory | UTTimedPowerup in the class tree, UTBerserk
and UTUDamage
, have the same function called GivenTo
which is inherited from Inventory
. Even though the function name is the same, they give the inventory items their unique behavior. UTBerserk
's GivenTo
function calls a function that increases the player's weapon firing rate, while UTUDamage
's GivenTo
function increases the player's DamageScaling
variable. These functions also set different sound effects and overlays for the two different items.
To experiment with function overriding we're going to expand our AwesomeGame
classes to include a custom GameInfo
and PlayerController
class. The GameInfo
controls the rules of the game and is what makes Deathmatch
different from "Capture the Flag" for example...