Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class BirdController : MonoBehaviour
- {
- public float jumpForce = 200f;
- private Rigidbody2D rb2d;
- void Start()
- {
- rb2d = GetComponent<Rigidbody2D>();
- }
- void Update()
- {
- if (Input.GetButtonDown("Jump"))
- {
- rb2d.velocity = Vector2.zero;
- rb2d.AddForce(new Vector2(0, jumpForce));
- }
- }
- void OnCollisionEnter2D(Collision2D other)
- {
- GameController.instance.BirdDied();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment