Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Bullet : MonoBehaviour
- {
- public float speedBullet;
- public float damage;
- private void OnTriggerEnter2D(Collider2D collision)
- {
- if(collision.CompareTag("Player"))
- {
- Health health = collision.GetComponent<Health>();
- health.TakeDamage(damage);
- Destroy(gameObject);
- }
- }
- private void Update()
- {
- transform.Translate(Vector3.right * speedBullet * Time.deltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement