Game Development Reference
In-Depth Information
void BuffDebuffStat(GameObject other)
{
other.SendMessage("BuffDebuffStat", new
KeyValuePair<string, int>(Stat, Amount));
}
This function, when called, receives a GameObject, which will be the GameObject
that we are affecting with the melee item. We then send a message to that GameOb-
ject to call the function that modifies the stats, and then pass the KeyValuePair to
it. The KeyValuePair contains the stat we want to modify as well as the amount
that we want to modify it by.
The health changer
The next function we'll add to the script will allow the melee item to change the health
of other GameObjects. Add the following function after the BuffDebuffStat func-
tion in our script:
void ChangeHealth(GameObject other)
{
other.SendMessage("ChangeHealth", Amount);
}
When this function is called, it will modify the health of the GameObject that the mel-
ee item collides with. This could mean healing or hurting the GameObject, but this
function can be used either way.
Let's interact with the environment
The last and final function will allow the player to interact with the environment. Add
this function to your script:
void ActivateEnvironment(GameObject other)
{
other.SendMessage("Activate");
}
Search WWH ::




Custom Search