Game Development Reference
In-Depth Information
}
break;
case "Environment":
if(rangedType != RangedType.None)
{
if(rangedAction == RangedAction.ChangeHP)
ChangeHealth(col.gameObject);
if(rangedAction ==
RangedAction.BuffDebuff)
BuffDebuffStat(col.gameObject);
if(rangedAction ==
RangedAction.ActivateEnv)
ActivateEnvironment(col.gameObject);
}
break;
}
Destroy(gameObject);
}
Just as in the melee item class, we use triggers to detect whether the projectile has
hit something; if it does, we take the collider of that GameObject. Once we have de-
tected the collision and received the collider, we follow these steps to decide what to
do next:
• In the switch statement, we use the tag of the GameObject collider to check
what it's colliding with
• We then check if the rangedType variable isn't equal to None
• Afterwards, we go through a few if statements to see what action we are
using
• Once the action has been found, we call its function accordingly
• While calling the function, we pass the GameObject as well
• Finally, after all this is done, we delete the projectile from the scene
At first, it may look confusing, but we are really just following a step-by-step process
of logic to decide what our projectile should do. With this, we conclude the projectile
Search WWH ::




Custom Search