Time for action – Detecting collisions to give our Pawn damage
As the physical representation of the player, the Pawn class uses the function TakeDamage
to subtract from our health, give us any momentum the weapon used has (such as rockets pushing us away when they explode), and tells the game what type of damage it was so it can play the appropriate effects and send the right death messages. We'll call that function from another function we're going to use, Bump.
While in the real world using Bump resurrects old forum threads, in the UDK it lets us know when two actors that have
bBlockActors
set totrue
run into each other. First, let's set a damage amount in ourTestEnemy
class. Add this variable toTestEnemy
:var float BumpDamage;
And give it a value in the default properties:
BumpDamage=5.0
Now let's add the
Bump
function to ourAwesomePawn
:event Bump(Actor Other, PrimitiveComponent OtherComp, vector HitNormal) { `log("Bump!"); if(TestEnemy(Other) != none) TakeDamage...