Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Ammo : MonoBehaviour
- {
- public float speed;
- public float destroyTime;
- public int damage = 2;
- void Start()
- {
- Invoke("DestroyAmmo", destroyTime);
- }
- void Update()
- {
- transform.Translate(Vector2.left * speed * Time.deltaTime);
- }
- private void OnTriggerEnter2D(Collider2D collision)
- {
- HpEnemy enemy = collision.GetComponent<HpEnemy>();
- if (enemy != null);
- {
- enemy.TakeDamage(damage);
- }
- Destroy(gameObject);
- }
- }
Add Comment
Please, Sign In to add comment