Ongoing C++ Gameplay Example Series: Making a Survival Game

Hiho!

Im trying to learn a bit using the project, and cannot set up proper headshot&limb damage for the player (i enabled pvp damage). Any help on why it doesnt work would be appreciated.

  1. I added 2 new surface types in project settings for player head and limbs
  2. Added 2 new physical materials cloning PlayerBody, and set the new surfaces there
  3. Changed in player’s PhysicsAsset head and limb surface - click on head at 3d model, set playerhead material for simple collision physical material
  4. For PlayerPawn set collision preset to custom, enable (query and physics), object type to Pawn, and set weapon at trace responses to block.
  5. Changed some code:
    SurvivalGame.h:

#define SURFACE_PLAYERHEAD          SurfaceType5
#define SURFACE_PLAYERLIMB          SurfaceType6


SWeaponInstant.cpp, changed DealDamage function a bit:


       ...
	if (PhysMat && DmgType)
	{
		if (PhysMat->SurfaceType == SURFACE_ZOMBIEHEAD || PhysMat->SurfaceType == SURFACE_PLAYERHEAD)
		{		
			ActualHitDamage *= DmgType->GetHeadDamageModifier();	
		}
		else if (PhysMat->SurfaceType == SURFACE_ZOMBIELIMB || PhysMat->SurfaceType == SURFACE_PLAYERLIMB)
		{
			ActualHitDamage *= DmgType->GetLimbDamageModifier();		
		}
	}