コインアイテムの取得



コインをゲットする
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ItemGet : MonoBehaviour
{
public AudioClip coinGet;
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.CompareTag("Coin"))
{
AudioSource.PlayClipAtPoint(coinGet, transform.position);
Destroy(collision.gameObject);
}
}
}





【2022版】ActionGame2D(全33回)
他のコースを見る


コインをゲットする
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ItemGet : MonoBehaviour
{
public AudioClip coinGet;
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.CompareTag("Coin"))
{
AudioSource.PlayClipAtPoint(coinGet, transform.position);
Destroy(collision.gameObject);
}
}
}





コインアイテムの取得