ºÇ½ª¹¹¿·¡§ orika_ex_miyako 2022ǯ03·î24Æü(ÌÚ) 15:31:38ÍúÎò
£±£²¡¥GameManager¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤¹¤ë£¡¡Æ±¤¸´³»ÙƱ»Î¤ò¥¹¥ï¥¤¥×¤·¤Æ·Ò¤²¤é¤ì¤ë¤è¤¦¤Ë¤¹¤ë
¡¡¿·¤·¤¤³Ø½¬ÆâÍƤϡ¢°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£
¡¦Vector2.Distance()¥á¥½¥Ã¥É
¡¡GameManager¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤Æ¡¢²èÌÌÆâ¤Î´³»ÙƱ»Î¤ò¥É¥é¥Ã¥°¡Ê¥¹¥ï¥¤¥×¡Ë¤·¤Æ¤Ä¤Ê¤²¤Æ¤¤¤¯½èÍý¤ò¼ÂÁõ¤·¤Æ¤¤¤¤Þ¤¹¡£
¹ç¤ï¤»¤Æ¡¢°Û¤Ê¤ë´³»ÙƱ»Î¤¬¤Ä¤Ê¤¬¤é¤Ê¤¤¤è¤¦¤Ë¤âÀ©¸æ¤·¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢¤½¤ÎÉôʬ¤â¥Ç¥Ð¥Ã¥°»þ¤Ë¤Ï³Îǧ¤ò¹Ô¤¤¤Þ¤¹¡£
¡¡£²¤Ä°Ê¾å¤ÎƱ¤¸´³»Ù¤ò¤Ä¤Ê¤²¤Æ¡¢Á°¤Î´³»Ù¤Ë¥É¥é¥Ã¥°¤òÌᤷ¤¿¾ì¹ç¡¢¤Ä¤Ê¤¬¤Ã¤Æ¤¤¤¿´³»ÙƱ»Î¤Î¤Ä¤Ê¤¬¤ê¤¬²ò½ü¤µ¤ì¤ë½èÍý¤â¼ÂÁõ¤·¤Þ¤¹¤Î¤Ç
¤³¤Á¤é¤â¥Ç¥Ð¥Ã¥°»þ¤Ë¤Ï˺¤ì¤º¤Ë³Îǧ¤ò¹Ô¤¤¤Þ¤¹¡£Î㤨¤Ð¡¢£³¤Ä¤Î´³»Ù¤¬¤Ä¤Ê¤¬¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ë£²¤ÄÌܤδ³»Ù¤Ë¥É¥é¥Ã¥°¤òÌᤷ¤¿¾ì¹ç¡¢
£³¤ÄÌܤδ³»Ù¤¬ºï½ü¤ÎÂоݤ«¤é³°¤ì¤Æ¡Êºï½ü¥ê¥¹¥È¤«¤é½ü³°¤µ¤ì¤Æ¡Ë¡¢´³»Ù¤ÎÆ©ÌÀÅÙ¤¬¸µ¤ÎÆ©ÌÀÅÙ¤ËÌá¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
GameManager.cs
¡¡Â裱°ú¿ô¤ÈÂ裲°ú¿ô¤Ë»ØÄꤷ¤¿Vector2·¿¤Î£²ÅÀ´Ö¤Îµ÷Î¥¤ò¡¢float·¿¤ËÊÑ´¹¤·¤Æµ÷Î¥¤È¤·¤ÆÌᤷ¤Æ¤¯¤ì¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£
Ìá¤êÃͤ˹ç¤ï¤»¤ÆÊդˤÏfloat·¿¤ÎÊÑ¿ô¤òÍÑ°Õ¤·¤ÆÂåÆþ¤µ¤»¤Þ¤¹¡£
// ¸½ºß¥¿¥Ã¥×¤·¤Æ¤¤¤ë´³»Ù¤Î°ÌÃÖ¾ðÊó¤ÈºÇ¸å¤Ë¥¿¥Ã¥×¤·¤¿´³»Ù¤Î°ÌÃÖ¾ðÊó¤ÈÈæ¤Ù¤Æ¡¢º¹Ê¬¤ÎÃÍ¡Ê´³»ÙÄ̤·¤Îµ÷Î¥¡Ë¤ò¼è¤ë float distance = Vector2.Distance(dragEto.transform.position, lastSelectEto.transform.position);¡¡
Unity¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
Vector2.Distance
https://docs.unity3d.com/ja/current/ScriptReferenc...
¡¡¥¹¥ï¥¤¥×½èÍý¤òÄɲä·¤Þ¤·¤¿¤Î¤Ç¡¢²èÌ̤δ³»Ù¤ò¥¿¥Ã¥×¤·¤¿¤Þ¤ÞƱ¤¸¼ïÎà¤Î´³»Ù¤Ø¤È¤½¤Î¤Þ¤Þ°ÜÆ°¤ò¤µ¤»¤Æ¤ß¤Þ¤·¤ç¤¦¡£
Editor¤Ç³Îǧ¤¹¤ë¾ì¹ç¤Ë¤Ï¡¢º¸¥¯¥ê¥Ã¥¯¤ò¤·¤¿¤Þ¤ÞƱ¤¸´³»Ù¤Ø¤È¥«¡¼¥½¥ë¤ò°ÜÆ°¤µ¤»¤Þ¤¹¡£
¡¡Æ±¤¸´³»ÙƱ»Î¤ò¤Ä¤Ê¤¬¤ë¤³¤È¤¬¤Ç¤¤ì¤Ð¡¢¤½¤Î¿·¤·¤¤´³»Ù¤ÎÆ©ÌÀÅÙ¤¬È¾Æ©ÌÀ¤Ë¤Ê¤ê¡¢GameManager¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ÎEraseEtoList¤ËÄɲ䵤ì¤Þ¤¹¡£
¡¡¤³¤Î¤È¤¡¢Ê̤βèÁü¤Î´³»ÙƱ»Î¤¬¤Ä¤Ê¤¬¤Ã¤Æ¤·¤Þ¤ï¤Ê¤¤¤«¤â¡¢¹ç¤ï¤»¤Æ³Îǧ¤ò¹Ô¤¤¤Þ¤¹¡£
¡¡¤Þ¤¿¡¢£²¤Ä°Ê¾å¤Î´³»Ù¤ò¤Ä¤Ê¤¤¤À¾õÂ֤ǣ±¤ÄÁ°¤Î´³»Ù¤Ë°ÜÆ°¤ò¤µ¤»¤¿¾ì¹ç¡¢¤Ä¤Ê¤¬¤Ã¤Æ¤¤¤¿´³»Ù¤¬¤Ä¤Ê¤¬¤Ã¤Æ¤¤¤Ê¤¤¾õÂÖ¤ËÌá¤ë¤«¤â³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£
¸¡¾ÚÆ°²è¡Ê¤Ä¤Ê¤¬¤Ã¤¿´³»ÙƱ»Î¤Î¿§¤¬È¾Æ©ÌÀ¤Ë¤Ê¤ë¡£Â¾¤Î²èÁü¤Î´³»Ù¤Ë¤Ï¤Ä¤Ê¤¬¤é¤Ê¤¤¡£Á°¤Î´³»Ù¤ËÌá¤ë¤È¤Ä¤Ê¤¬¤ê¤¬²ò½ü¤µ¤ì¤ë¡Ë
https://gyazo.com/9fdc1ac54f3a558ac17eb37fa6b34f19
GameManager¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¤¥ó¥¹¥Ú¥¯¥¿¡¼Æ°²è¡Ê´³»ÙƱ»Î¤¬¤Ä¤Ê¤¬¤Ã¤¿¤ê¡¢¤Ä¤Ê¤¬¤ê¤¬²ò½ü¤µ¤ì¤¿¤ê¤¹¤ë¤¿¤Ó¤Ë¡¢EraseEtoList¤ËÄɲᦺï½ü¤¬¹Ô¤ï¤ì¤ë¡Ë
https://gyazo.com/9fdc1ac54f3a558ac17eb37fa6b34f19
¡¡°Ê¾å¤Ç¤³¤Î¼ê½ç¤Ï½ªÎ»¤Ç¤¹¡£
¡¡¼¡¤Ï ¼ê½ç£· ¤Ç¤¹¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- ¥×¥í¥°¥é¥ß¥ó¥°
¥³¥á¥ó¥È¤ò¤«¤¯