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

¡¡ÆÃÄê¤Î¥Ü¥¿¥ó¤ò²¡¤·¤¿ºÝ¤Ë¥¢¥¤¥Æ¥à¤ò¼èÆÀ¤¹¤ëµ¡Ç½¤Î¼ÂÁõÎã¤Ç¤¹¡£

¡¡¥¢¥¤¥Æ¥à¤Ë¿¨¤ì¤¿¤é¼«Æ°Åª¤Ë¥¢¥¤¥Æ¥à¤ò¼èÆÀ¤¹¤ë¥¿¥¤¥×¤Î¼ÂÁõÊýË¡¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£









Àß·×


¡¡ÆÃÄê¤Î¥Ü¥¿¥ó¤ò²¡¤·¤¿ºÝ¤Ë¡¢¥³¥é¥¤¥À¡¼¤ò»ý¤Ä¸«¤¨¤Ê¤¤¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ò¥×¥ì¥¤¥ä¡¼¤Î¼þ°Ï¤ËŸ³«¤·¡¢
¤½¤Î¥³¥é¥¤¥À¡¼¤ÎÈÏ°ÏÆâ¤Ë¤¢¤ë¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÀººº¤·¤Æ¡¢¥¢¥¤¥Æ¥à¤Ç¤¢¤Ã¤¿¾ì¹ç¤Ë¤Ï¼èÆÀ¤¹¤ë¤È¤¤¤¦µ¡Ç½¤Ç¤¹¡£

¡¡¶ñÂÎŪ¤Ê¥¢¥¤¥Æ¥à¤Î¸ú²Ì¤Ê¤É¤Ï´Þ¤ß¤Þ¤»¤ó¤Î¤Ç¡¢¤½¤ÎÉôʬ¤Ë¤Ä¤¤¤Æ¤ÏÊÌÅÓ¡¢¼ÂÁõ¤ò¤ª¤³¤Ê¤Ã¤Æ¤¯¤À¤µ¤¤¡£

¡¡¥¢¥¤¥Æ¥à¤ÎȽÄêÊýË¡¤Ë¤Ä¤¤¤Æ¡¢¤³¤³¤Ç¤ÏÊ£¿ô¤Î¥¢¥×¥í¡¼¥Á¤òÄ󼨤·¤Þ¤¹¡£
¼èÆÀ»þ¤Îµ¡Ç½(¥³¥é¥¤¥À¡¼¤ÎŸ³«Éôʬ)¤Ï¡¢¤¹¤Ù¤ÆƱ¤¸µ¡Ç½¤òÍøÍѤ·¤Æ¤¤¤Þ¤¹¡£

¡¡¤Ê¤ªµ­»ö¼«ÂΤϣ³£ÄÍѤǤ¹¤¬¡¢£²£Ä¤Ç¤â±þÍѲÄǽ¤Ç¤¹¡£


£±¡¥¥¿¥°¤Ë¤è¤ëȽÄêÊýË¡


¡¡¤â¤Ã¤È¤â°ìÈÌŪ¤Ç¡¢¼ÂÁõ¤¬ÍưפÊÊýË¡¤Ç¤¹¡£



¡¡<=¡¡¥¯¥ê¥Ã¥¯¤¹¤ë¤È³«¤­¤Þ¤¹¡£




¡¡»öÁ°¤Ë¥¿¥°¤òºîÀ®¤·¡¢¸¡½Ð¤µ¤ì¤ë¦(¥¢¥¤¥Æ¥à¦)¤Ë¥¿¥°¤òÀßÄꤷ¤Æ¤ª¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¡£
¤Þ¤¿¡¢¥¿¥°¤Ë¤è¤ëȽÄê¤Ïʸ»úÎó¤Ç¤¢¤ë¤¿¤á¡¢Âçʸ»ú¾®Ê¸»ú¤Î¶èÊ̤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢´Ö°ã¤¨¤Ê¤¤¤è¤¦¤ËºîÀ®¤·¤Æ¤¯¤À¤µ¤¤¡£

¡¡¹½Ê¸Æâ¤Ç¤Ï¡¢if ʸ¤Ë¤è¤ë¥Í¥¹¥È(Æþ¤ì»Ò¹½Â¤)¤ò¿¼¤¯¤Ê¤é¤Ê¤¤¤è¤¦¤Ë¡¢continue ¤ò¤·¤Æ¤¤¤Þ¤¹¡£

¡¡¾ò·ï¤¬À®Î©¤·¤¿¤é¡¢¤È¤¤¤¦·Á¤Ç½èÍý¤òºî¤ë¤À¤±¤Ç¤Ï¤Ê¤¯¡¢¾ò·ï¤¬À®Î©¤·¤Ê¤«¤Ã¤¿¤é¡¢¤È¤¤¤¦·Á¤Ç½èÍý¤òºî¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£


¡ãPhysics.OverlapSphere ¥á¥½¥Ã¥É¡ä


¡¡Unity ¤Î Physics ¥¯¥é¥¹¤ËÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¥á¥½¥Ã¥É¤Î£±¤Ä¤Ç¤¹¡£µåÂηÁ¤Î¥³¥é¥¤¥À¡¼¤ò°ì»þŪ¤ËÀ¸À®¤·¡¢Â¾¤Î¥³¥é¥¤¥À¡¼¤È¤Î¿¯ÆþȽÄê¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
ȽÄê·ë²Ì¤È¤·¤Æ¡¢Collider ÇÛÎ󷿤ÎÌá¤êÃͤò»ý¤Á¤Þ¤¹¡£

¡¡Â¾¤Ë¤â .OverlapBox ¥á¥½¥Ã¥É¡¢OverlapCapsule ¥á¥½¥Ã¥É¤¬¤¢¤ê¡¢¤½¤ì¤¾¤ì¤Ë·Á¾õ¤¬°ã¤¤¤Þ¤¹¡£Ìá¤êÃͤϤ¤¤º¤ì¤â Collider ÇÛÎ󷿤ÇƱ¤¸¤Ç¤¹¡£


// ¥­¥ã¥é¥¯¥¿¡¼¤òÃæ¿´¤Ë¡¢radius ¤òȾ·Â¤È¤·¤¿±ß·Á¤Î¥³¥é¥¤¥À¡¼¤òºîÀ®¤·¡¢¤½¤ÎÈÏ°ÏÆâ¤Ë¤¢¤ë¤¹¤Ù¤Æ¤Î¥³¥é¥¤¥À¡¼¤ò¸¡½Ð¤·¤ÆÇÛÎó¤Ë¤¹¤ë
Collider[] hitColliders = Physics.OverlapSphere(transform.position, radius); 

¡¡OverlapSphere ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤È¡¢Âè1°ú¿ô¤Î°ÌÃÖ¤ò»ÏÅÀ¤Ë¡¢Âè2°ú¿ô¤ÎÃͤòȾ·Â¤È¤·¤¿±ß·Á¤Î¥³¥é¥¤¥À¡¼¤òŸ³«¤·¤Þ¤¹¡£
¤³¤Î¤È¤­¡¢¤³¤Î¥³¥é¥¤¥À¡¼¤ÎÈÏ°ÏÆâ¤Ë¤¢¤ë¡¢Ê̤Υ²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤ò¸¡½Ð¤·¡¢¤½¤ì¤é¤ò¤Þ¤È¤á¤ÆÇÛÎó¤ËÆþ¤ì¤ÆÌá¤êÃͤȤ·¤ÆÄ󶡤·¤Þ¤¹¡£

¡¡¤½¤Î¤¿¤áº£²ó¤Î¤è¤¦¤Ë¡¢¥³¥é¥¤¥À¡¼ÇÛÎ󷿤ÎÊÑ¿ô¤òÍÑ°Õ¤·¤Æ¤ª¤¯¤³¤È¤ÇÂåÆþ¤·¡¢°Ê¹ß¤Î½èÍý¤ÇÍøÍѤ·¤Æ¤¤¤¯¤³¤È¤¬½ÐÍè¤Þ¤¹¡£

¡¡¤³¤Î¥á¥½¥Ã¥É¤Ë¤Ï OverlapSphereNonAlloc ¥á¥½¥Ã¥É¤âÍÑ°Õ¤µ¤ì¤Æ¤ª¤ê¡¢¤³¤Á¤é¤ÎÊý¤¬¥¬¥Ù¡¼¥¸¤òÀ¸À®¤·¤Ê¤¤Ê¬Í¥¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢»öÁ°¤ËÇÛÎó¤ÎŤµ¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
ÍøÍÑÊýË¡¤òÍý²ò¤Ç¤­¤Æ¤­¤¿¤é¡¢¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤·¤Æ½èÍý¤ÎÃÖ¤­´¹¤¨¤Ë¥Á¥ã¥ì¥ó¥¸¤·¤Æ¤ß¤ë¤È¤è¤¤¤Ç¤·¤ç¤¦¡£


»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¡¦¥ê¥Õ¥¡¥ì¥ó¥¹
Physics.OverlapSphere
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¡¦¥ê¥Õ¥¡¥ì¥ó¥¹
Physics.OverlapSphereNonAlloc



¡¡£²£ÄÍѤâÍÑ°Õ¤µ¤ì¤Æ¤Þ¤¹¡£
¥á¥½¥Ã¥É̾¤Ï OverlapSphere ¤Ç¤Ï¤Ê¤¯¡¢OverlapCircle ¥á¥½¥Ã¥É¤È OverlapCircleNonAlloc ¥á¥½¥Ã¥É¤Ç¤¹¡£


»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¡¦¥ê¥Õ¥¡¥ì¥ó¥¹
Physics2D.OverlapCircle
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¡¦¥ê¥Õ¥¡¥ì¥ó¥¹
Physics2D.OverlapCircleNonAlloc


£²¡¥¥ì¥¤¥ä¡¼¤Ë¤è¤ëȽÄê


¡¡Àè¤Û¤ÉÍøÍѤ·¤Æ¤¤¤ë Physics.OverlapSphere ¥á¥½¥Ã¥É¤Î°ú¿ô¤Ë¤ÏÂè3°ú¿ô¤ÈÂè4°ú¿ô¤¬¤¢¤ê¡¢¤³¤Á¤é¤Ë¤Ï½é´üÃͤ¬ÂåÆþ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢Âè2°ú¿ô¤Þ¤Ç»ØÄꤹ¤ì¤ÐÍøÍѤǤ­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£

¡¡Âè3°ú¿ô¤Ë¤Ï¥ì¥¤¥ä¡¼¤Î»ØÄ꤬¤Ç¤­¤ë¤¿¤á¡¢¤½¤Î¾ì¹ç¡¢Physics.OverlapSphere ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤È¡¢¥á¥½¥Ã¥É¤ÎÈÏ°ÏÆâ¤Ë¤¢¤ë¡¢»ØÄꤷ¤¿¥ì¥¤¥ä¡¼¤Î¤ß¤òÇÛÎó¤È¤·¤Æ¼èÆÀ½ÐÍè¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢if ʸ¤Ë¤è¤ëȽÄê¤ò¾Êά¤Ç¤­¤Þ¤¹¡£


¡¡<=¡¡¥¯¥ê¥Ã¥¯¤¹¤ë¤È³«¤­¤Þ¤¹¡£




¡¡»öÁ°¤Ë¥ì¥¤¥ä¡¼¤òºîÀ®¤·¡¢¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤Ç¸¡½Ð¤·¤¿¤¤¥ì¥¤¥ä¡¼¤ò»ØÄꤷ¤Þ¤¹¡£
¤Þ¤¿¡¢¸¡½Ð¤µ¤ì¤ë¦(¥¢¥¤¥Æ¥à¦)¤Ë¥ì¥¤¥ä¡¼¤òÀßÄꤷ¤Æ¤ª¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¡£

¡¡ÍøÅÀ¤È¤·¤Æ¤Ï¡¢Physics.OverlapSphere ¥á¥½¥Ã¥É¤Ç¸¡½Ð¤µ¤ì¤ë¥³¥é¥¤¥À¡¼¤ò¤Õ¤ë¤¤¤Ë¤«¤±¤Æ¡¢»ØÄꤷ¤¿¥ì¥¤¥ä¡¼¤Î¾ðÊó¤Î¤ß¤ÇÌá¤êÃͤòºîÀ®¤Ç¤­¤ë¤³¤È¤Ç¤¹¡£
¤½¤Î¤¿¤á¡¢ÇÛÎó¤ÎÃæ¿È¤Ï¤¹¤Ù¤Æ»ØÄꤷ¤¿¥ì¥¤¥ä¡¼¤Î¥³¥é¥¤¥À¡¼¤Î¤ß¤Ç¤¢¤ë¤³¤È¤¬Êݾڤµ¤ì¤ë¤¿¤á¡¢¥¿¥°¤È¤Ï°Û¤Ê¤ê¡¢if ʸ¤Ë¤è¤ëȽÄ꤬ÉÔÍפˤʤäƤ¤¤Þ¤¹¡£


£³¡¥¥¯¥é¥¹¤Ë¤è¤ëȽÄêÊýË¡


¡¡Á°½Ò¤Î¥ì¥¤¥ä¡¼¤ò¥Ù¡¼¥¹¤Ë¡¢½èÍý¤Î¼ÂÍÑŪ¤Ë¤·¤Æ¸úΨ²½¤ò¤ª¤³¤Ê¤Ã¤¿¹½Ê¸¤Ç¤¹¡£


¡¡<=¡¡¥¯¥ê¥Ã¥¯¤¹¤ë¤È³«¤­¤Þ¤¹¡£




¡¡¥¢¥¤¥Æ¥à½èÍý¤ÎÃê¾Ý²½¤ò¥Ù¡¼¥¹¤Ë¡¢ItemBase ¥¯¥é¥¹¤ò¼èÆÀ¤Ç¤­¤ë¤«¤ò³Îǧ¤·¤Æ¤¤¤Þ¤¹¡£
¥¿¥°¤ä¥ì¥¤¥ä¡¼¤Ç¤ÎȽÄê¤Î¾ì¹ç¡¢¥¢¥¤¥Æ¥à¤Î¸ú²Ì¤òÍøÍѤ¹¤ë¥¿¥¤¥ß¥ó¥°¤ÇÊÌÅÓ¡¢¥¢¥¤¥Æ¥à¤Î¥¯¥é¥¹¤Î¼èÆÀ(GetComponent ¥á¥½¥Ã¥É)¤¬É¬Íפˤʤê¤Þ¤¹¤¬
¤³¤Á¤é¤Î¥¢¥×¥í¡¼¥Á¤Ç¤¢¤ì¤Ð¤¹¤Ç¤Ë¥¯¥é¥¹¤ò¼èÆÀ¤·¤Æ¤¤¤ë¤Î¤Ç GetComponent ¥á¥½¥Ã¥É¤¬ÉÔÍפǤ¹¡£(¤¹¤°¤ËÌ¿Î᤬½Ð¤»¤Þ¤¹¡£)

¡¡¤Ç¤­¤ë¸Â¤ê¡¢¥¿¥°¤ä¥ì¥¤¥ä¡¼¤Ç¤ÎȽÄê¤Ç¤Ï¤Ê¤¯¡¢¥¯¥é¥¹¤Ç¤ÎȽÄê¤ò¹Ô¤¦¤è¤¦¤Ë¤·¤Þ¤¹¡£
¤½¤·¤Æ¥ì¥¤¥ä¡¼¤Ë¤Ä¤¤¤Æ¤Ï¡¢³èÍѤǤ­¤ëÉôʬ¤Ç¤Ï¾å¼ê¤¯ÁȤ߹ç¤ï¤»¤Æ¤¤¤­¤Þ¤·¤ç¤¦¡£


¡ãȯŸ·Á¡ä¥¤¥Ù¥ó¥È¶îÆ°·¿¤Ë¤è¤ë¼ÂÁõÎã


¡¡UniRx ¤Îµ¡Ç½¤òÍøÍѤ·¤Æ¡¢¥Ü¥¿¥ó¤ÎȽÄê¤ò¥¤¥Ù¥ó¥È¶îÆ°·¿¤Ë¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤·¤¿¤â¤Î¤Ç¤¹¡£
¥¢¥¤¥Æ¥à¤ÎȽÄêÊýË¡¤Ï¡Ú£³¡¥¥¯¥é¥¹¤Ë¤è¤ëȽÄêÊýË¡¡Û¤òºÎÍѤ·¤Æ¤¤¤Þ¤¹¡£


¡¡<=¡¡¥¯¥ê¥Ã¥¯¤¹¤ë¤È³«¤­¤Þ¤¹¡£




¡¡Update ¥á¥½¥Ã¥ÉÆâ¤Ç½èÍý¤·¤Æ¤¤¤¿¥Ü¥¿¥ó¤Î²¡²¼³Îǧ½èÍý¤ò Start ¥á¥½¥Ã¥ÉÆâ¤Ç¤Î¥Ü¥¿¥ó¤Î¹ØÆɽèÍý¤Ë¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤·¤Æ¤¤¤Þ¤¹¡£


¤Þ¤È¤á


¡¡¤³¤Î¤è¤¦¤Ë¥¢¥¤¥Æ¥à¤ÎȽÄêÊýË¡¤À¤±¤Ç¤âÊ£¿ô¤Î¥¢¥×¥í¡¼¥Á¤¬¤¢¤ê¤Þ¤¹¡£
¿§¡¹¤ÊÊýË¡¤ò¼ÂÁõ¤·¡¢³Ø½¬¤·¤Æ¤ª¤¯¤³¤È¤Ç¥¹¥­¥ë¤ÎÉý¤¬¹­¤¬¤ê¤Þ¤¹¡£

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


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

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

Menu


´ðÁÃ

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

private



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

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