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 FatBird : MonoBehaviour
- {
- public float jumpForse;
- public float waitSeconds;
- public Transform groundCheck;
- public LayerMask whatIsGround;
- private bool isGrounded;
- public float checkRadius;
- public ParticleSystem dust;
- private Rigidbody2D rb;
- void Start()
- {
- rb = GetComponent<Rigidbody2D>();
- StartCoroutine(UpdateRoutine());
- }
- IEnumerator UpdateRoutine()
- {
- while (true)
- {
- JumpBird();
- yield return new WaitForSeconds(waitSeconds * 1f);
- }
- }
- private void Update()
- {
- if (isGrounded == false)
- {
- CreateDust();
- }
- }
- private void FixedUpdate()
- {
- isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
- }
- void JumpBird()
- {
- rb.velocity = Vector2.up * jumpForse;
- }
- void CreateDust()
- {
- dust.Play();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement