technix/Assets/script/movement/Bullet.cs

20 lines
455 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
Rigidbody2D rb;
public float damage;
public float time = 2f;
public void ApplyVel(Vector2 dir,float speed) {
rb = GetComponent<Rigidbody2D>();
rb.velocity = dir * speed;
Destroy(gameObject, time);
}
private void OnCollisionEnter2D(Collision2D c) {
Destroy(gameObject);
}
}