using System.Collections; using System.Collections.Generic; using UnityEngine; public class BubbleBlock : MonoBehaviour { private GameObject Player; private bool Up; public float TimeUp; public float Speed; private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") { Player = collision.gameObject; Up = true; Player.GetComponent().BB = this; Invoke("Stop", TimeUp); } } private void Update() { if (Up) { transform.Translate(Vector3.up * Speed * Time.deltaTime); Player.gameObject.transform.position = transform.position; } } public void Stop() { Player.GetComponent().WakeUp(); Up = false; Player.GetComponent().linearVelocity = Vector2.up * Player.GetComponent().jumpforce; Destroy(this.gameObject); } }