You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
641 B
28 lines
641 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Bullet : MonoBehaviour
|
|
{
|
|
public Rigidbody2D rb;
|
|
[System.NonSerialized]public int setDmg;
|
|
private int Damage;
|
|
private void Start()
|
|
{
|
|
Damage = setDmg;
|
|
rb.AddForce(Vector2.right * 20);
|
|
}
|
|
private void OnCollisionEnter2D(Collision2D other)
|
|
{
|
|
if(other.collider.CompareTag("Player"))
|
|
{
|
|
return;
|
|
}
|
|
if(other.collider.TryGetComponent<Health>(out Health health))
|
|
{
|
|
health.RemoveHP(Damage);
|
|
}
|
|
GameObject.Destroy(gameObject);
|
|
}
|
|
}
|