Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BirbController : MonoBehaviour
- {
- // bool canJump = true;
- float lastTime;
- bool _isDead;
- public bool IsDead
- {
- get
- {
- return _isDead;
- }
- set
- {
- _isDead = value;
- Destroy(this.gameObject);
- GameManager.RestartGame();
- }
- }
- Rigidbody2D rb2D;
- void Start()
- {
- lastTime = Time.time - 0.25f;
- rb2D = gameObject.GetComponent<Rigidbody2D>();
- }
- void Update()
- {
- HandleMovement();
- }
- void HandleMovement()
- {
- if (Input.GetKeyDown(KeyCode.Space) && (Time.time - lastTime >= 0.25f))
- {
- lastTime = Time.time;
- Debug.Log("Jump");
- rb2D.velocity = Vector2.zero;
- rb2D.AddForce(Vector2.up * 250);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement