initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Collectible2D : MonoBehaviour
|
||||
{
|
||||
|
||||
public float rotationSpeed = 0.5f;
|
||||
public GameObject onCollectEffect;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
transform.Rotate(0, 0, rotationSpeed);
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other) {
|
||||
|
||||
// Check if the other object has a PlayerController2D component
|
||||
if (other.GetComponent<PlayerController2D>() != null) {
|
||||
|
||||
// Destroy the collectible
|
||||
Destroy(gameObject);
|
||||
|
||||
// Instantiate the particle effect
|
||||
Instantiate(onCollectEffect, transform.position, transform.rotation);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user