karen_constantine

Untitled

Apr 9th, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class BirdController : MonoBehaviour
  4. {
  5. public float jumpForce = 200f;
  6.  
  7. private Rigidbody2D rb2d;
  8.  
  9. void Start()
  10. {
  11. rb2d = GetComponent<Rigidbody2D>();
  12. }
  13.  
  14. void Update()
  15. {
  16. if (Input.GetButtonDown("Jump"))
  17. {
  18. rb2d.velocity = Vector2.zero;
  19. rb2d.AddForce(new Vector2(0, jumpForce));
  20. }
  21. }
  22.  
  23. void OnCollisionEnter2D(Collision2D other)
  24. {
  25. GameController.instance.BirdDied();
  26. }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment