using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float speed = -20f;
public Rigidbody2D rb;
public int damage = 30;
void Start()
{
rb.velocity = transform.right * speed;
}
void OnTriggerEnter2D(Collider2D hitInfo)
{
Enemy enemy = hitInfo.GetComponent();
if (enemy != null)
{
enemy.TakeDamage(damage);
}
Destroy(gameObject);
}
}
//It’s my bullet script. Not sure what the deal is. Created 2d sprite, gave it a graphic that I can see. Gave it a rigidbody 2d and a circle collider 2d. Tossed this on to it, dropped it into my weapon script slot. I fire, nothing in the console but no projectile. I made an enemy, doesn’t do damage to it.