Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. public class BulletScript : MonoBehaviour
  2. {
  3.     public float velX = 0f;
  4.     public float velY = 5f;
  5.     private Rigidbody2D rb;
  6.     private int scoreInt;
  7.     public Text score;
  8.     // Start is called before the first frame update
  9.     void Start()
  10.     {
  11.         rb = GetComponent<Rigidbody2D>();
  12.     }
  13.  
  14.     // Update is called once per frame
  15.     void Update()
  16.     {
  17.         rb.velocity = new Vector2(velX,velY*30);
  18.     }
  19.    
  20.     void OnCollisionEnter2D(Collision2D coll)
  21.     {
  22.         if (coll.gameObject.CompareTag("Lemon"))
  23.         {
  24.             Destroy(gameObject);
  25.             Destroy(coll.gameObject);
  26.             scoreInt += 1;
  27.             score.text = scoreInt.ToString();
  28.         }
  29.     }
  30.    
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement