VG:Health Packs

From MyProjectFun
Jump to: navigation, search

Student: I've been asked by someone for my health pack code, so I'll post it here for anyone else who wants it

//Find the player we're hitting
Sprite Player = This.Sprite.CollisionWithSprite("Player" );
 
//if we have the player
if (Player != null)
{
 
  //Get his local data
  PlayerData PD = Player.GetLocalData<PlayerData>();
 
  //if his health is not full
  if (PD.Health < *insert your player health here*)
  {
 
    //Add one health
    ++PD.Health;
 
 
    //Delete me
    This.Sprite.Delete();
  }
}
Personal tools
Namespaces
Variants
Actions
Navigation
Engineering
Game Design
Multimedia Production
VG Programming
Downloads
Toolbox