Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BulletScript : MonoBehaviour
- {
- public float velX = 0f;
- public float velY = 5f;
- private Rigidbody2D rb;
- private int scoreInt;
- public Text score;
- // Start is called before the first frame update
- void Start()
- {
- rb = GetComponent<Rigidbody2D>();
- }
- // Update is called once per frame
- void Update()
- {
- rb.velocity = new Vector2(velX,velY*30);
- }
- void OnCollisionEnter2D(Collision2D coll)
- {
- if (coll.gameObject.CompareTag("Lemon"))
- {
- Destroy(gameObject);
- Destroy(coll.gameObject);
- scoreInt += 1;
- score.text = scoreInt.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement