WaterShieldProjectile.cs 524 Bytes
Newer Older
1 2 3 4 5 6
using UnityEngine;
using System.Collections;

public class WaterShieldProjectile : MonoBehaviour {

	[HideInInspector]
7
	public int damage = 1;
8 9 10 11 12 13 14 15 16 17 18 19 20 21
	public float speed;
	private Rigidbody2D rb;
	[HideInInspector]
	public Vector2 direction;


	void Start () {
		rb = GetComponent<Rigidbody2D>();
		rb.velocity = (direction * speed);
	}



	void OnCollisionEnter2D(Collision2D c){
22 23 24 25 26
		if(c.transform.CompareTag("Enemy")){
			Debug.Log ("hit");
			c.transform.SendMessage ("GetHit", damage);
		}

27 28 29
		Destroy (this.gameObject);
	}
}