using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bullet : MonoBehaviour {

    private Rigidbody rigid;

    [SerializeField]
    private float force = 10;

    [SerializeField]
    private uint damage = 10;

    void Awake () {
        this.rigid = GetComponent<Rigidbody>();
        this.rigid.AddRelativeForce (Vector3.forward * force, ForceMode.VelocityChange);

        Destroy(this.gameObject, 3f);
    }

    void OnCollisionEnter(Collision collision)
    {

        var player = collision.gameObject.GetComponent<Character>();
        if (player) {
            player.Health.DealDamage(this.damage);
        }

        Destroy(this.gameObject);
    }
}
