Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BulletScript : MonoBehaviour
- {
- public float speed = 5f;
- void Start()
- {
- //ustawiamy po jakim czasie nas pocisk zniknie
- Destroy(gameObject,3);
- }
- // Update is called once per frame
- void Update()
- {
- //poruszamy pociskiem
- Move();
- }
- void Move()
- {
- //przesuwamy się w górę o naszą prędkość
- transform.position += Vector3.up * speed * Time.deltaTime;
- }
- private void OnTriggerEnter2D(Collider2D collision)
- {
- if (collision.gameObject.tag == "Alien" || collision.gameObject.tag == "AlienBullet")
- {
- Destroy(collision.gameObject);
- Destroy(gameObject);
- }
- }
- }
Add Comment
Please, Sign In to add comment