Unity¤Ë´ØÏ¢¤¹¤ëµ­»ö¤Ç¤¹

Àß·×


¡¡°Û¤Ê¤ë¿§¤Î¥Ö¥í¥Ã¥¯¤ò¿·¤·¤¯£±¤Äºî¤ê¡¢Âѵ×ÅÙ¡ÊÇ˲õ¤·¤Ë¤¯¤µ¡Ë¤òÄɲ䷤ƥ²¡¼¥àÀ­¤òÁý²Ã¤µ¤»¤Þ¤¹¡£
¤Þ¤¿¡¢¤¹¤Ç¤Ë¤¢¤ë¥Ö¥í¥Ã¥¯¤È¤Ï°Û¤Ê¤ëÅÀ¿ô¤ò»ý¤¿¤»¤ë¤³¤È¤Ç¡¢¥×¥ì¥¤¥ä¡¼¤ËÇ˲õ¤·¤Ë¤¯¤¤¤¬ÅÀ¿ô¤¬¹â¤¤¡¢¤È¤¤¤¦¥·¥¹¥Æ¥à¤òÄ󼨤Ǥ­¤Þ¤¹¡£

¼ÂÁõ¼ê½ç


¡¡°Ê²¼¤Î¼ê½ç¤Ç¼ÂÁõ¤·¤Þ¤¹¡£

£±¡¥Box¥×¥ì¥Õ¥¡¥Ö¤òÍøÍѤ·¤Æ¡¢¿·¤·¤¤Box¡ÊHardBox¡Ë¤òºîÀ®¤·¤Æ¥×¥ì¥Õ¥¡¥Ö¤Ë¤·¤Þ¤¹¡£
£²¡¥Destroyer¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤Þ¤¹¡£
£³¡¥¤µ¤é¤Ë¥Ö¥í¥Ã¥¯¤Î¼ïÎà¤òÁý¤ä¤·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢£±¤Î¼ê½ç¤ò·«¤êÊÖ¤·¤Þ¤¹¡£


£±¡¥Box¥×¥ì¥Õ¥¡¥Ö¤òÍøÍѤ·¤Æ¡¢¿·¤·¤¤Box¡ÊHardBox¡Ë¤òºîÀ®¤·¤Æ¥×¥ì¥Õ¥¡¥Ö¤Ë¤·¤Þ¤¹¡£


¡¡¥Ò¥¨¥é¥ë¥­¡¼Æâ¤Ë¡¢Prefabs¥Õ¥©¥ë¥À¤Ë¤¢¤ëBox¥×¥ì¥Õ¥¡¥Ö¡¦¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ò¥É¥é¥Ã¥°¡õ¥É¥í¥Ã¥×¤·¤Þ¤¹¡£
¤½¤Î¸å¡¢¤³¤ÎBox¤Î̾¾Î¤òÊѹ¹¤·¤Þ¤¹¡£¡ÊHardBox¡¢¤Ê¤É¡Ë
¤³¤ÎBox¤ò¸µ¤Ë°Û¤Ê¤ë¿§¤ÎBox¤òºîÀ®¤·¤Æ¤¤¤­¤Þ¤¹¡£

¡¡Materials¥Õ¥©¥ë¥À¤ÎÃæ¤Ç±¦¥¯¥ê¥Ã¥¯¤ò¤·¤Æ¡¢create -> Material¤òÁªÂò¤·¡¢¹¥¤­¤Ê̾¾Î( HardBoxMaterial ¤Ê¤É)¤òÉÕ¤±¤Æ¿·¤·¤¤¿§¤òºîÀ®¤·¤Þ¤¹¡£
¤½¤Î¿·¤·¤¤Material¤òHardBox¤Ë¥É¥é¥Ã¥°¡õ¥É¥í¥Ã¥×¤·¤Þ¤¹¡£¤³¤ì¤Ç¿§¤¬Êѹ¹¤Ë¤Ê¤ê¤Þ¤¹¡£



¡¡HardBox¤ò¥Ò¥¨¥é¥ë¥­¡¼¤è¤ê¡¢Prefabs¥Õ¥©¥ë¥À¤Ë¥É¥é¥Ã¥°¡õ¥É¥í¥Ã¥×¤·¤Þ¤¹¡£
¥Ò¥¨¥é¥ë¥­¡¼¤ÎHardBox¤Îʸ»ú¤Î¿§¤¬ÀÄ»ú¤Ë¤Ê¤ì¤Ð̵»ö¤Ë¥×¥ì¥Õ¥¡¥Ö²½¤Ç¤­¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¸å¡¢¥Ò¥¨¥é¥ë¥­¡¼¤è¤êºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£




£²¡¥Destroyer¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤Þ¤¹¡£


¡¡Â³¤¤¤Æ¡¢Destroyer.cs¤ò½¤Àµ¤·¡¢Âѵ×ÎϤäSE¤Ê¤É¤òÄɲä·¤Þ¤¹¡£

Destroyer.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Destroyer : MonoBehaviour {

    public int point;              //  ÆÀÅÀ
¡¡¡¡public GameObject masterObj;¡¡ //  "Master"¤È¤¤¤¦Ì¾Á°¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥ÈÍÑ

    public int initHp;                 //  Âѵ×ÎϤκÇÂçÃÍ          <- ¤³¤³¤«¤é
    private int currentHp;             //  Âѵ×ÎϤθ½ºßÃÍ

    public AudioClip hitSE;        //  Ç˲õ¤µ¤ì¤Ê¤¤¾ì¹ç¤ÎSE    
    public AudioClip destroySE;     //  Ç˲õ¤µ¤ì¤¿¾ì¹ç¤ÎSE
 
    void Start () 
    {
        //  Box¤ÎÂѵ×ÎϤò½é´ü²½¤·¤Þ¤¹¡£(¸½ºßÃÍ¡áºÇÂçÃͤˤ¹¤ë)     
        this.currentHp = initHp;                                      
    }

    private void OnCollisionEnter(Collision collision)
    {
        //  ¥Ü¡¼¥ë¤¬ÀÜ¿¨¤¹¤ë¤¿¤Ó¤Ë¡¢Âѵ×ÎϤò1¤º¤Ä¸º¤é¤·¤Þ¤¹¡£     
        this.currentHp -= 1;

        //  ²õ¤ì¤ë¾ì¹ç
        if (this.currentHp <= 0)
        {
¡¡¡¡¡¡¡¡¡¡¡¡//  Ç˲õ¤µ¤ì¤ëSE¤òºÆÀ¸
            AudioSource.PlayClipAtPoint(DestroySE, transform.position);
            // »Ä¤ê¤Î¥Ö¥í¥Ã¥¯¿ô¤ò£±¤Ä¸º¤é¤¹
            masterObj.GetComponent<GameMaster>().boxNum--;
            // ¥¹¥³¥¢¤ò²Ã»»¤¹¤ë
            FindObjectOfType<Score>().AddPoint(point);
            // ¤³¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¡Ê¥Ö¥í¥Ã¥¯¡Ë¤òÇ˲õ¤¹¤ë¡¡¡¡¡¡¡¡
            Destroy(this.gameObject);
        }
        //  ¤Þ¤À²õ¤ì¤Ê¤¤¾ì¹ç
        else
        {
            //  ¥Ü¡¼¥ë¤òÄ·¤ÍÊÖ¤¹SE¤òºÆÀ¸
            AudioSource.PlayClipAtPoint(hitSE, transform.position);     
        }                                                               < - ¤³¤³¤Þ¤Ç
    }
}

¡¡public¤ÇÍÑ°Õ¤·¤¿ÊÑ¿ô¤¬Â¿¤¤¤Î¤Ç¡¢¿ôÃͤÎÆþÎϤäSE²»¸»¥Õ¥¡¥¤¥ëÍѤΥ³¥ó¥Ý¡¼¥Í¥ó¥È¤òÄɲ䷤ơ¢¥¢¥µ¥¤¥ó¤·¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£



¡¡¤Þ¤¿¡¢SE¤Ë¤Ä¤¤¤Æ¤Ï¡¢Destroyer ¥¹¥¯¥ê¥×¥ÈÆâ¤Ë HitPlaySound ¤Îµ¡Ç½(Ç˲õ»þ¤ÈÈóÇ˲õ»þ¤Çʬ´ô¤¬È¯À¸¤¹¤ë¤¿¤á¡Ë¤òÄɲ䷤Ƥ¢¤ê¤Þ¤¹¤Î¤Ç¡¢
ÀèÄø¥¢¥¿¥Ã¥Á¤·¤¿HitPlaySound.cs¤ÏÉÔÍפǤ¹¡£Box¤è¤ê¥¢¥¿¥Ã¥Á¤ò²ò½ü¤·¤Æ¤ª¤­¤Þ¤¹¡£

¡¡PrefabsÆâ¤ÎBox¤òÁªÂò¤·¡¢¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤Î¥¹¥¯¥ê¥×¥È¤òÁª¤ó¤ÇRemove Component¤ò¤·¤Æ¤¯¤À¤µ¤¤¡£
Destroyer ¥¹¥¯¥ê¥×¥È¤¬ÉÕ¤¤¤Æ¤¤¤ë¾¤ÎBox¤Ë¤Ä¤¤¤Æ¤â¡¢Æ±¤¸¤è¤¦¤Ë Remove Compnent ¤ò¤ª¤³¤Ê¤Ã¤Æ¤¯¤À¤µ¤¤¡£


£³¡¥¤µ¤é¤Ë¥Ö¥í¥Ã¥¯¤Î¼ïÎà¤òÁý¤ä¤·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢£±¤Î¼ê½ç¤ò·«¤êÊÖ¤·¤Þ¤¹¡£


¡¡¼¡¤Î¼ÂÁõ¤Ë¤Æ¡¢°Û¤Ê¤ë¥Ö¥í¥Ã¥¯¤ò¥é¥ó¥À¥à¤ËÀ¸À®¤¹¤ë½èÍý¤ò¹Ô¤¤¤Þ¤¹¡£°Û¤Ê¤ë¥Ö¥í¥Ã¥¯¤¬Â¿¤¤¤Û¤É¥é¥ó¥À¥àÀ­¤¬Áý¤·¤Þ¤¹¤Î¤Ç
HardBox°Ê³°¤Ë¤âBox¤òºîÀ®¤·¤Æ¥×¥ì¥Õ¥¡¥Ö¤Ë¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£¤½¤Î¾ì¹ç¤Ë¤Ï¡¢É¬¤º£±¤Ä¤º¤Ä¿§¤òÊѤ¨¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£

¥³¥á¥ó¥È¤ò¤«¤¯


¡Öhttp://¡×¤ò´Þ¤àÅê¹Æ¤Ï¶Ø»ß¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

ÍøÍѵ¬Ìó¤ò¤´³Îǧ¤Î¤¦¤¨¤´µ­Æþ²¼¤µ¤¤

Menu


´ðÁÃ

µ»½Ñ/Ãμ±(¼ÂÁõÎã)

3D¥¢¥¯¥·¥ç¥ó¥²¡¼¥à

2D¤ª¤Ï¤¸¤­¥²¡¼¥à(ȯŸÊÔ)

2D¶¯À©²£¥¹¥¯¥í¡¼¥ë¥¢¥¯¥·¥ç¥ó(ȯŸÊÔ)

2D¥¿¥Ã¥×¥·¥å¡¼¥Æ¥£¥ó¥°(³ÈÄ¥ÊÔ)

¥ì¡¼¥¹¥²¡¼¥à(È´¿è)

2DÊüÃÖ¥²¡¼¥à(ȯŸÊÔ)

3D¥ì¡¼¥ë¥¬¥ó¥·¥å¡¼¥Æ¥£¥ó¥°(±þÍÑÊÔ)

3Dæ½Ð¥²¡¼¥à(È´¿è)

2D¥ê¥¢¥ë¥¿¥¤¥à¥¹¥È¥é¥Æ¥¸¡¼

3D¥¿¥Ã¥×¥¢¥¯¥·¥ç¥ó(NavMeshAgent »ÈÍÑ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥«¥¨¥ë¤Î°Ù¤Ë¡Á¡¢¥Ü¥³¥¹¥«¥¦¥©¡¼¥ºÉ÷)

VideoPlayer ¥¤¥Ù¥ó¥ÈϢư¤Î¼ÂÁõÎã

VideoPlayer ¥ê¥¹¥ÈÆ⤫¤é¥à¡¼¥Ó¡¼ºÆÀ¸¤Î¼ÂÁõÎã(ȯŸ)

AR ²èÁüÉÕ¤­¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¤Î¼ÂÁõÎã

AR ¥ê¥¹¥ÈÆ⤫¤éÀ¸À®¤Î¼ÂÁõÎã(ȯŸ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥µ¥Ð¥¤¥Ð¡¼É÷)

private



¤³¤Î¥µ¥¤¥ÈÆâ¤ÎºîÉʤϥæ¥Ë¥Æ¥£¤Á¤ã¤ó¥é¥¤¥»¥ó¥¹¾ò¹à¤Î¸µ¤ËÄ󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£

´ÉÍý¿Í/Éû´ÉÍý¿Í¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹