Add destructive herd from left.

posted in: Weekly Progress | 0

Death herd is added at the  left side of the game scene if player will go to the left side after some time he will collide with death herd, it is added to difficult the game to somehow.

 

here is the code :

 

using UnityEngine;
using System.Collections;

public class DeathHerdController : MonoBehaviour
{
public float Speed;
public int Damage;

protected Player _player;

// Use this for initialization
void Start ()
{
_player = AnimalSpawnManager.PlayerPrefab.GetComponent<Player>();
}

// Update is called once per frame
void Update ()
{
transform.Translate( Speed * Time.deltaTime , 0, 0, Camera.main.transform);
}

void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.GetComponent<Player>() != null)
{
_player.GiveDamageByDeathHerd(Damage);
}
}
}

Leave a Reply