Skip to content

Ved-ant17/GGJ25

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

using UnityEngine;

public class CrabBubbleEmitter : MonoBehaviour { public GameObject bubblePrefab; // Assign your bubble prefab here public Transform emitPoint; // Point where the bubble will spawn public float bubbleSpeed = 2f; // Speed of the emitted bubble public float emitInterval = 3f; // Interval between bubble emissions

private bool canEmit = true;

void OnTriggerEnter2D(Collider2D other)
{
    if (other.CompareTag("PlayerBubble") && canEmit)
    {
        EmitBubble();
        StartCoroutine(EmitCooldown());
    }
}

void EmitBubble()
{
    // Instantiate the bubble at the emit point
    GameObject bubble = Instantiate(bubblePrefab, emitPoint.position, Quaternion.identity);

    // Set the bubble's velocity to move upward
    Rigidbody2D rb = bubble.GetComponent<Rigidbody2D>();
    if (rb != null)
    {
        rb.velocity = Vector2.up * bubbleSpeed;
    }
}

System.Collections.IEnumerator EmitCooldown()
{
    canEmit = false;
    yield return new WaitForSeconds(emitInterval);
    canEmit = true;
}

}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors