Game Development Reference
In-Depth Information
Now let's take a look at the DropMovement code:
transform.Translate(new Vector3(0, DropSpeed,
1) * (Time.deltaTime * Speed));
This line is similar to the BasicMovement line, but our movement Vector is differ-
ent. We use the DropSpeed variable in the y axis to make our projectile drop to the
ground. It will appear as if gravity is acting on our projectile, giving it a more realist-
ic appearance. Dropping the projectile will also make it a little more difficult for the
player to attack, adding a new mechanic to the game.
Detecting triggers
Now we'll add detection method to our projectile. We will use a similar system that
we used in the melee item class. Add the following code to your script:
void OnTriggerEnter(Collider col)
{
switch(col.gameObject.tag)
{
case "Enemy":
if(rangedType == RangedType.Weapon)
{
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);
}
Search WWH ::




Custom Search