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

¡¡º£¸å¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤¬Áý¤¨¤ë¤³¤È¤òÁÛÄꤷ¤Æ¡¢¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤òÊ̤μêË¡¤ËÊѹ¹¤ò¹Ô¤¤¤Þ¤¹¡£
¤³¤ì¤Ï¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤Ë¤Ê¤ê¤Þ¤¹¤Î¤Ç¡¢¥²¡¼¥à¾å¤ÎµóÆ°¤ÏÊѤï¤é¤º¡¢¥¹¥¯¥ê¥×¥È¤ÎÆâÍƤò²þ½¤¤¹¤ëÆâÍƤˤʤê¤Þ¤¹¡£

¡¡°Ê²¼¤ÎÆâÍƤǽçÈ֤˼ÂÁõ¤ò¿Ê¤á¤Æ¤¤¤­¤Þ¤¹¡£

ȯŸ£±£±¡¡¡Ý¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÍѤΥ¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ÎºîÀ®¤È±¿ÍÑ¡Ý
£²£±¡¥¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÍѤΠMoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤¹¤ë
£²£²¡¥¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤Ë±þ¤¸¤Æ MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ËÍÑ°Õ¤µ¤ì¤¿¥á¥½¥Ã¥É¤ò UnityAction ¤ËÅÐÏ¿¤·¤Æ°ÜÆ°¤ò¼Â¹Ô¤¹¤ë



¡¡¿·¤·¤¤³Ø½¬ÆâÍƤϡ¢°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£

¡¡¡¦¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î¿·¤·¤¤»È¤¤Êý
¡¡¡¦UnityAction(¥Ç¥ê¥²¡¼¥È)¤Î»È¤¤Êý
¡¡¡¦DOAnchorPos ¥á¥½¥Ã¥É



£²£±¡¥¥¨¥Í¥ß¡¼ÍѤΰÜÆ°ÍѤΥ¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤¹¤ë

£±¡¥Àß·×


¡¡¤³¤Î¼ê½ç¤Ç¤Ï¡¢¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤Ë¤Ä¤¤¤Æ¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤ò¹Ô¤¤¤Þ¤¹¡£
¿·¤·¤¤µ¡Ç½¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢½ñ¤¤¤Æ¤¢¤ëÆâÍƤ¬Æñ¤·¤¤¡¢¼ÂÁõ¤·¤¿¤¤¤±¤É½èÍý¤¬Æɤá¤Ê¤¤¡¢¤È¤¤¤¦¾ì¹ç¤Ë¤Ï¤³¤Î¼ê½ç¤ÏÈô¤Ð¤·¤Æ¤¯¤À¤µ¤¤¡£
¼«Ê¬¤Î¥¹¥­¥ë¤Ë¹ç¤ï¤»¤Æ³Ø½¬¤ò¹Ô¤Ã¤Æ¤¤¤¿¤À¤±¤ì¤ÐÌäÂꤢ¤ê¤Þ¤»¤ó¡£¤¢¤È¤Ç¿¶¤êÊ֤äƤߤƤ¯¤À¤µ¤¤¡£



¡¡¥¨¥Í¥ß¡¼ÍѤΥǡ¼¥¿¥Ù¡¼¥¹¤È¤·¤ÆÍøÍѤ¹¤ëÌÜŪ¤Ç EnemyDataSO ¥¹¥¯¥ê¥×¥È¤òºîÀ®¤·¡¢
EnemyDataSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤·¤Æ¡¢ÀßÄê¤ò¹Ô¤Ã¤Æ¤­¤Þ¤·¤¿¡£

¡¡¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤Ï¤³¤Î¤è¤¦¤Ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤È¤·¤ÆÍøÍѤǤ­¤ëÉôʬ¤Î¾¤Ë¡¢
ÆÃÄê¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë°Í¸¤·¤Ê¤¤(ɳ¤Å¤«¤Ê¤¤)¡¢¤È¤¤¤¦ÆÃÀ­¤òÀ¸¤«¤·¤Æ¡¢
´ØÏ¢¤¹¤ë¥á¥½¥Ã¥É¤òÅÐÏ¿¤·¤Æ¥á¥½¥Ã¥É¤ò°·¤¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤È¤·¤ÆÍøÍѤ¹¤ëÊýË¡¤¬¤¢¤ê¤Þ¤¹¡£

¡¡¸½ºß¥¨¥Í¥ß¡¼¤Î°ÜÆ°¤Ë¤Ä¤¤¤Æ¤Ï EnemyController ¥¹¥¯¥ê¥×¥È¤Ëµ­½Ò¤ò¤·¤Æ¤­¤Þ¤·¤¿¡£
º£¤Î½ê£²¤Ä¤Î°ÜÆ°ÊýË¡¤¬¥á¥½¥Ã¥É¤È¤·¤ÆºîÀ®¤µ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢¤³¤ì¤Ë¤Ï£²¤Ä¤ÎÂ礭¤ÊÌäÂêÅÀ¤¬¤¢¤ê¤Þ¤¹¡£

¡¡¤Þ¤º£±¤Ä¤¬¡¢°ÜÆ°ÊýË¡¤¬£±¤ÄÁý¤¨¤ë¤¿¤Ó¤Ë¡¢EnemyController ¥¹¥¯¥ê¥×¥È¼«ÂΤ¬ÈîÂç²½¤·¤Æ¤·¤Þ¤¦¤È¤¤¤¦¤³¤È¡¢
¤â¤¦£±¤Ä¤Ï¡¢¥¨¥Í¥ß¡¼¤¬ÍøÍѤ¹¤ë°ÜÆ°ÊýË¡¤Ï£±¤Ä¤Î¤Ï¤º¤Ê¤Î¤Ë¡¢Â¾¤ËÍøÍѤ·¤Ê¤¤°ÜÆ°¤Î¾ðÊó¤â´ÉÍý¤·¤Æ¤¤¤ë¤È¤¤¤¦¤³¤È¡¢¤³¤Î£²¤Ä¤Ç¤¹¡£

¡¡Î㤨¤Ð¥¨¥Í¥ß¡¼¤Î¼ïÎà¤òÁý¤ä¤·¤Æ°ÜÆ°ÊýË¡¤ò£µ¼ïÎà¤ËÁý¤ä¤¹¡¢¤È²¾Äꤷ¤Æ¹Í¤¨¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
£µ¤Ä¤Î°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ò EnemyController ¥¹¥¯¥ê¥×¥È¤ËÄɲ乤뤳¤È¤Ë¤Ê¤ê¤Þ¤¹¤¬¡¢
¼ÂºÝ¤Ë£µ¤Ä¤Î¥á¥½¥Ã¥É¤ò¤¹¤Ù¤ÆÍøÍѤ¹¤ë¥¨¥Í¥ß¡¼¤Ï¸ºß¤·¤Þ¤»¤ó¡£¤¤¤º¤ì¤«£±¤Ä¤Î°ÜÆ°ÍѤΥ᥽¥Ã¥É¤¬¤¢¤ì¤Ð½¼Ê¬¤Ê¤Ï¤º¤Ç¤¹¡£

¡¡¤½¤·¤Æ¥á¥½¥Ã¥É¤¬Áý¤¨¤ë¤È¤¤¤¦¤³¤È¤Ï¡¢EnemyController ¥¹¥¯¥ê¥×¥È¤Ëµ­½Ò¤µ¤ì¤ë½èÍý¤¬É¬Á³Åª¤ËÁý¤¨¤Æ¤¤¤­¤Þ¤¹¡£
°ÜÆ°½èÍý°Ê³°¤Î¥á¥½¥Ã¥É¤Ï¥¨¥Í¥ß¡¼¤Î´ÉÍý¤ä±¿¹Ô¤Ë¹ç¤ï¤»¤ÆɬÍפʥ᥽¥Ã¥É¤äÊÑ¿ô¤Ç¹½À®¤µ¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢
ËÜÍè¤ÏɬÍפʾðÊó¤Î¤ß¤Ç£±¤Ä¤Î¥¹¥¯¥ê¥×¥È¤¬¹½À®¤µ¤ì¤Æ¤¤¤ë¤³¤È¤¬ÍýÁÛŪ¤Ç¤¹¡£

¡¡¤³¤ÎÉôʬ¤ÎÌäÂêÅÀ¤ò²ò·è¤¹¤ëÊýË¡¤Î£±¤Ä¤È¤·¤Æ¡¢º£²ó¤Ï¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òÍøÍѤ·¤Þ¤¹¡£
¤â¤Á¤í¤ó¡¢Â¾¤Ë¤âÊýË¡¤Ï¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢¤¤¤¯¤Ä¤«¤¢¤ëÃæ¤Î£±¤Ä¡¢¤È¤·¤Æª¤¨¤Æ¤ª¤¯¤³¤È¤¬ÂçÀڤǤ¹¡£»ëÌî¤Ï¹­¤¯»ý¤Ã¤Æ¤ª¤­¤Þ¤·¤ç¤¦¡£



¡¡¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤Ë¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÍѤΥ᥽¥Ã¥É¤òÍÑ°Õ¤·¡¢¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤Ë¹ç¤ï¤»¤ÆŬÀڤʥ᥽¥Ã¥É¤ò½àÈ÷¤·¤Þ¤¹¡£
EnemyController ¥¹¥¯¥ê¥×¥È¦¤Ç¤Ï¡¢¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤è¤ê¡¢¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤Ë¹ç¤ï¤»¤¿¥á¥½¥Ã¥É¤ò£±¤Ä¡¢¼èÆÀ¤·¤Þ¤¹¡£
¤½¤·¤Æ¤½¤ì¤ò¼Â¹Ô¤¹¤ë¡¢¤È¤¤¤¦Î®¤ì¤Ë¤Ê¤ê¤Þ¤¹¡£

¡¡¤³¤Î½èÍý¤ò¼ÂÁõ¤¹¤ë¤¿¤á¤Ë¤Ï¡¢UnityAction ¤È¤¤¤¦ Unity ¤¬ÍÑ°Õ¤·¤Æ¤¤¤ë½èÍý¤òÍøÍѤ·¤Þ¤¹¡£
UnityAction ¤Ï¥Ç¥ê¥²¡¼¥È¤È¸Æ¤Ð¤ì¤ë C#¡¡¥×¥í¥°¥é¥à¤Îµ¡Ç½¤òÍøÍѤ·¤Æ¤¤¤ë½èÍý¤Ç¤¹¡£
¥Ç¥ê¥²¡¼¥È¤È¤Ï¥á¥½¥Ã¥É¤ò»²¾È¤¹¤ë·¿¤Î¤³¤È¤ò¸À¤¤¤Þ¤¹¡£
¡¡
¡¡¼ÂºÝ¤ËÍøÍѤ¹¤ë¾ì¹ç¤Ë¤Ï¡¢¥á¥½¥Ã¥É¤òÅÐÏ¿¤·¤Æ¤ª¤±¤ëÊÑ¿ô¡¢¤È¤¤¤¦¥Ë¥å¥¢¥ó¥¹¤Ç¹Í¤¨¤Æ¤â¤é¤Ã¤Æ¤âÌäÂꤢ¤ê¤Þ¤»¤ó¡£
ÊÑ¿ô¤ÎÃͤȤ·¤Æ¥á¥½¥Ã¥É¤òÅÐÏ¿¤·¤Æ¤ª¤¯¤³¤È¤Ç¡¢¤½¤ÎÊÑ¿ô¤ò¼Â¹Ô¤¹¤ë·Á¤Ç¡¢ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë½èÍý¤È¤È¤é¤¨¤ë¤È¤¤¤¤¤Ç¤¹¡£

¡¡¼ÂºÝ¤ËºîÀ®¤·¤Ê¤¬¤é½èÍý¤ò¸«¤Æ¤¤¤­¤Þ¤¹¡£


£²¡¥MoveEventSO ¥¹¥¯¥ê¥×¥È¤òºîÀ®¤¹¤ë


¡¡¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤¹¤ë¤¿¤á¤ËɬÍפʾðÊó¤äµ­½Ò¤ÎÊýË¡¤Ï³Ð¤¨¤Æ¤¤¤Þ¤¹¤«¡©
ȯŸ£² ¤Ë¾ÜºÙ¤Ê¼ê½ç¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢Éü½¬¤·¤Ê¤¬¤é½èÍý¤òµ­½Ò¤·¤Æ¤¤¤­¤Þ¤·¤ç¤¦¡£

¡¡º£²ó¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¤È¤·¤ÆÍøÍѤ¹¤ëÌõ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤Î¤Ç¡¢List ¤äÆþ¤ì»Ò¥¯¥é¥¹¤Ê¤É¤ÎÀë¸À¤ÏÉÔÍפǤ¹¡£
Âå¤ï¤ê¤Ë¡¢º£¤Þ¤Ç EnemyController ¥¹¥¯¥ê¥×¥È¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤¿°ÜÆ°ÊýË¡¤Ë¤è¤Ã¤Æʬ´ô¤ò¹Ô¤¦¥á¥½¥Ã¥É¤È¡¢°ÜÆ°¤Î½èÍý¤ò¹Ô¤¦¥á¥½¥Ã¥É¤òµ­½ÒÊýË¡¤òÊѤ¨¤ÆÍÑ°Õ¤·¤Þ¤¹¡£

¡¡ÊÑ¿ô¤Ç¤Ï const ¥­¡¼¥ï¡¼¥É¤òÍøÍѤ·¤Æ¤¤¤Þ¤¹¡£¤³¤Î¥­¡¼¥ï¡¼¥É¤òÀë¸À¤·¤¿ÊÑ¿ô¤ÎÃͤÏÄê¿ô¤È¤·¤Æ°·¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¡¢¥²¡¼¥àÆâ¤Ç¤ÎÃͤÎÊѹ¹¤¬½ÐÍè¤Ê¤¯¤Ê¤ê¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢¥²¡¼¥àÆâ¤ÇÍøÍѤ¹¤ëºÝ¤ËÄêÃÍ(¥²¡¼¥à³«»Ï¤«¤é½ª¤ï¤ê¤Þ¤ÇÊѤï¤é¤Ê¤¤ÃÍ)¤ò°·¤¦¾ì¹ç¤Ë¤ÏÀë¸À¤·¤Æ¤ª¤¯¤³¤È¤Ç¡¢ÃͤÎÊѹ¹¤òËɤ°¤³¤È¤¬½ÐÍè¤Þ¤¹¡£

»²¹Í¥µ¥¤¥È
Microsoft const (C# ¥ê¥Õ¥¡¥ì¥ó¥¹)
https://docs.microsoft.com/ja-jp/dotnet/csharp/lan...


MoveEventSO.cs

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


¡¡¥¹¥¯¥ê¥×¥È¤òºîÀ®¤·¤¿¤é¥»¡¼¥Ö¤·¤Þ¤¹¡£


£³¡¥MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤¹¤ë


¡¡Unity ¤Îº¸¾å¤Î¥á¥Ë¥å¡¼¤è¤ê¡¢Assets => Create => Create MoveEventSO ¤òÁªÂò¤·¤Þ¤¹¡£
¿·¤·¤¯ MoveEventSO ¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£Ì¾Á°¤Ï¤½¤Î¤Þ¤Þ¤Ç¹½¤¤¤Þ¤»¤ó¡£

¡¡MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ò Datas ¥Õ¥©¥ë¥À¤Ø°ÜÆ°¤·¤Æ¤¯¤À¤µ¤¤¡£
¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤·¤¿¤é¡¢Datas ¥Õ¥©¥ë¥ÀÆâ¤Ç´ÉÍý¤¹¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£

¡¡¥Ç¡¼¥¿¥Ù¡¼¥¹¤È¤·¤Æ¿ôÃͤò´ÉÍý¤¹¤ë¤¿¤á¤ËÍøÍѤ¹¤ëÌõ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤Î¤Ç¡¢ÀßÄê¤ÏÉÔÍפǤ¹¡£
MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤ò¸«¤Æ¤âÅÐÏ¿¤Ç¤­¤ë¤è¤¦¤Ê¾ðÊó¤Ï¤¢¤ê¤Þ¤»¤ó¡£


£´¡¥EnemyGenerator ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤Æ¡¢MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òÍøÍѤǤ­¤ë¾õÂ֤ˤ¹¤ë


¡¡¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ï¤¤¤º¤ì¤«¤Î¥¹¥¯¥ê¥×¥È¤ËÊÑ¿ô¤òÍÑ°Õ¤¹¤ë¤³¤È¤ÇÍøÍѲÄǽ¤Ë¤Ê¤ê¤Þ¤¹¡£
¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤òÀßÄꤷ¡¢°ÜÆ°½èÍý¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¥¢¥»¥Ã¥È¤Ë¤Ê¤ê¤Þ¤¹¤Î¤Ç¡¢º£²ó¤â EnemyGenerator ¥¹¥¯¥ê¥×¥È¤Ë
public ½¤¾þ»Ò¤Î MoveEventSO ·¿¤ÎÊÑ¿ô¤òÍÑ°Õ¤·¤Æ¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤è¤ê¥¢¥µ¥¤¥ó¤Ç¤­¤ë¤è¤¦¤Ë¤·¤Þ¤·¤ç¤¦¡£

¡¡¤Ê¤ª¡¢·¿¤Ï MoveEventSO ·¿¤Ç¤ÎÀë¸À¤Ë¤Ê¤ê¤Þ¤¹¤¬¡¢¥¢¥µ¥¤¥ó²Äǽ¤Ê¤Î¤Ï¡¢MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¹¡£
MoveEventSO ¥¹¥¯¥ê¥×¥È¤ÏľÀÜ¥¢¥µ¥¤¥ó¤Ç¤­¤Þ¤»¤ó¡£²¿¸Î¤Ê¤é¤Ð¡¢¥¢¥µ¥¤¥ó½ÐÍè¤ë¾ðÊó¤Ï¡¢¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤«¡¢ÆÃÄê¤Î¥¢¥»¥Ã¥È¤Ë¸Â¤é¤ì¤ë¤¿¤á¤Ç¤¹¡£
(º£¤Þ¤Ç¤Î¥¢¥µ¥¤¥ó¤ò»×¤¤½Ð¤·¤Æ¤¯¤À¤µ¤¤¡£¥Ò¥¨¥é¥ë¥­¡¼¤Ë¤¢¤ë¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¡¢¤¢¤ë¤¤¤Ï¥×¥ì¥Õ¥¡¥Ö¤Î¤ß¤ò¥¢¥µ¥¤¥ó¤·¤Æ¤¤¤ë¤Ï¤º¤Ç¤¹)
º®Æ±¤·¤ä¤¹¤¤¤Î¤Ç´Ö°ã¤¨¤Ê¤¤¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£

¡¡¤Þ¤¿Ìµ»ö¤Ë¥¨¥Í¥ß¡¼¤Î¼ïÎऴ¤È¤Ë List ¤¬ºîÀ®¤µ¤ì¤ë¤³¤È¤¬³Îǧ¤Ç¤­¤Þ¤·¤¿¤Î¤Ç¡¢
normalEnemyDatas ÊÑ¿ô¤È bossEnemyDatas ÊÑ¿ô¤Ë¤Ä¤¤¤Æ¤Ï pulbic ½¤¾þ»Ò¤Ç¤Ï¤Ê¤¯¡¢private ½¤¾þ»Ò¤ËÊѹ¹¤·¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£


EnemyGenerator.cs

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


¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¥»¡¼¥Ö¤·¤Þ¤¹¡£



¡¡EnemyGenerator ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤ò³Îǧ¤·¤Æ¡¢private ½¤¾þ»Ò¤ËÊѹ¹¤·¤¿ÊÑ¿ô¤Îɽ¼¨¤¬¤Ê¤¯¤Ê¤ê¡¢
¿·¤·¤¯ public ½¤¾þ»Ò¤ÇÀë¸À¤·¤¿ÊÑ¿ô¤¬É½¼¨¤µ¤ì¤Æ¤¤¤ë¤«¤ò³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£


EnemyGenerator ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¡¡¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü




£µ¡¥EnemyGenerator ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ÎÀßÄê¤ò¹Ô¤¦


¡¡MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥ÈÍѤÎÊÑ¿ô¤òÀë¸À¤·¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢Datas ¥Õ¥©¥ë¥À¤Ë¤¢¤ë
MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ò¥É¥é¥Ã¥°¥¢¥ó¥É¥É¥í¥Ã¥×¤·¤Æ¥¢¥µ¥¤¥ó¤·¤ÆÅÐÏ¿¤·¤Æ¤¯¤À¤µ¤¤¡£

¡¡MoveEventSO ¥¹¥¯¥ê¥×¥È¤ÏÅÐÏ¿¤Ç¤­¤Þ¤»¤ó¡£¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ÎÊý¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£


EnemyGenerator ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¡¡¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü



¡¡°Ê¾å¤ÇÀßÄê¤Ï´°Î»¤Ç¤¹¡£¤³¤ì¤Ç MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òÍøÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤·¤¿¡£


£²£²¡¥¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤Ë±þ¤¸¤Æ MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ËÍÑ°Õ¤µ¤ì¤¿¥á¥½¥Ã¥É¤ò UnityAction ¤ËÅÐÏ¿¤·¤Æ°ÜÆ°¤ò¼Â¹Ô¤¹¤ë

£±¡¥Àß·×


¡¡¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ò¤¹¤Ù¤Æ MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤Þ¤È¤á¤Æµ­½Ò¤·¤Þ¤·¤¿¡£
¤³¤Á¤é¤ò¥¨¥Í¥ß¡¼¤Î¥Ç¡¼¥¿¤ò»²¾È¤·¤¿¤È¤­¤Î¤è¤¦¤Ë¡¢¥¨¥Í¥ß¡¼¤Î MoveType ¤Î¼ïÎà¤Ë±þ¤¸¤Æ¡¢ÂоݤȤʤë°ÜÆ°Íѥ᥽¥Ã¥É¤ò¼èÆÀ¤·¤ÆÍøÍѽÐÍè¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
¡¡
¡¡¤³¤³¤Ç¤ÏÀè¤Û¤ÉÀâÌÀ¤·¤¿¡¢UnityAction ¤È¤¤¤¦µ¡Ç½¤òÍøÍѤ·¤Þ¤¹¡£¤³¤Î·¿¤òÊÑ¿ô¤òÍÑ°Õ¤¹¤ë¤³¤È¤Ç¡¢°ÜÆ°ÍѤΥ᥽¥Ã¥É¤òÊÑ¿ô¤ËÂåÆþ¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢EnemyController ¥¹¥¯¥ê¥×¥È¤Ë¤¢¤ë°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ò°ìÀڻȤ鷺¤Ë¡¢°ÜÆ°¤Î½èÍý¤ò¼Â¹Ô½ÐÍè¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£

¡¡¼ê½ç¤È¤·¤Æ¤Ï¡¢¥¨¥Í¥ß¡¼¤Ë¤¢¤ë EnemData ¥¯¥é¥¹Æâ¤Ë¤¢¤ë MoveType ¤òÍøÍѤ·¤Æ¡¢¤É¤Î°ÜÆ°ÊýË¡¤Ë¤¹¤ë¤¬Ê¬´ô¤¹¤ëÉôʬ¤ÏƱ¤¸¤Ç¤¹¤¬¡¢
¤³¤³¤Ç¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ò UnityAction ·¿¤ÎÊÑ¿ô¤ËÅÐÏ¿¤¹¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£

¡¡¤½¤Î¸å¡¢EnemyController ¥¹¥¯¥ê¥×¥È¤Ç¤ÏÅÐÏ¿¤µ¤ì¤¿¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¤Þ¤¹¡£
¤³¤Î¤è¤¦¤Ë¤¹¤ë¤³¤È¤Ç¡¢EnemyController ¥¹¥¯¥ê¥×¥È¤Ë¤Ï¡¢°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ò½ñ¤¯¤³¤È¤Ê¤¯¡¢¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤Ë±þ¤¸¤¿°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ò½èÍý½ÐÍè¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£

¡ã¥í¥¸¥Ã¥¯¤Îή¤ì¡ä
¡¡£±¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤Ë UnityActon ·¿¤ÎÊÑ¿ô¤òÍÑ°Õ¤¹¤ë
¡¡£²¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤«¤é¡¢MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î GetMoveEvent ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¡£°ú¿ô¤È¤·¤Æ¡¢¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡(MoveType)¤òÅϤ¹
¡¡¡¡¡¡¡¡¤³¤Î½èÍý¤ò¼Â¹Ô¤¹¤ë¤ËºÝ¤·¡¢GetMoveEvent ¥á¥½¥Ã¥É¤Ë¤ÏÌá¤êÃͤȤ·¤Æ UnityActon ·¿¤Ç°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ò¼èÆÀ¤·¤ÆÌᤷ¤Æ¤¯¤ì¤ë¤Î¤Ç¡¢¼õ¤±¼è¤Ã¤ÆÅÐÏ¿¤¹¤ë¤¿¤á¤Î UnityActon ·¿¤ÎÊÑ¿ô¤òº¸ÊÕ¤ËÍÑ°Õ¤·¤Æ¤ª¤¯
¡¡£³¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤Ë¤Æ¡¢UnityActon ·¿¤ÎÊÑ¿ô¤ËÅÐÏ¿¤µ¤ì¤¿°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¡£¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÊýË¡¤Ë±þ¤¸¤¿°ÜÆ°¤¬½èÍý¤µ¤ì¤ë

¡¡°Ê¾å¤Î¤è¤¦¤Êή¤ì¤Ë¤Ê¤ê¤Þ¤¹¡£

»²¹Í¥µ¥¤¥È
Unity¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
UnityAction
https://docs.unity3d.com/ja/current/ScriptReferenc...
Kan ¤Î¥á¥âÄ¢ ÍÍ
¥Ç¥ê¥²¡¼¥È(Delegate)¤ä¥¤¥Ù¥ó¥È(Event)¤È¤Ï¡ÚC#¡Û
https://kan-kikuchi.hatenablog.com/entry/Delegate


£²¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤¹¤ë


¡¡UnityActon ·¿¤òÀë¸À¤¹¤ë¤¿¤á¤Ë¤Ï using ¤ËÀë¸À¤ÎÄɲä¬É¬Íפˤʤê¤Þ¤¹¡£

¡¡UnityActon ·¿¤Ë¤Ï <T> ¤È¤¤¤¦¥¸¥§¥Í¥ê¥Ã¥¯·¿(Ǥ°Õ¤Î·¿)¤Ç¤Î·¿¥Ñ¥é¥á¡¼¥¿¤Î»ØÄ꤬½ÐÍè¤Þ¤¹¡£ºÇÂç¤Ç£´¤Ä¤Þ¤Ç»ØÄê¤Ç¤­¤Þ¤¹¡£
º£²ó¤Ï UnityAction<Transform, float> ·¿¤È¤¤¤¦·¿¤Ë¤Ê¤ê¡¢½èÍý¤ò¼Â¹Ô¤¹¤ëºÝ¤Ë·¿¥Ñ¥é¥á¡¼¥¿¤Ç»ØÄꤷ¤¿·¿¤Î¾ðÊó¤¬É¬Íפˤʤê¤Þ¤¹¡£


EnemyController.cs


¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¥»¡¼¥Ö¤·¤Þ¤¹¡£


£³¡¥UnityAction ¤Ë´Ø¤¹¤ë°ìÏ¢¤Î½èÍý¤òÆɤ߲ò¤¯


¡¡½èÍý¤ò½çÈÖ¤ËÆɤ߲ò¤¤¤Æ¤ß¤Þ¤·¤ç¤¦¡£

¡ãEnemyController.cs¡ä
  // ÊÑ¿ô¤òÍÑ°Õ¤¹¤ë
  private UnityAction<Transform, float> moveEvent; 

¡¡¤³¤³¤Ë°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ò¼èÆÀ¤·¤ÆÂåÆþ¤·¤Þ¤¹¡£

  // MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î GetMoveEvent ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¡¢Ìá¤êÃͤǰÜÆ°ÍѤΥ᥽¥Ã¥É¤ò¼õ¤±¼è¤ë¡£¤³¤³¤Ç°ÜÆ°ÊýË¡¤ò·èÄê
  moveEvent = this.enemyGenerator.moveEventSO.GetMoveEvent(enemyData.moveType);

¡¡¢­¡¡±¦ÊդνèÍý¤Ï¡¢°Ê²¼¤ÎÄ̤ê

¡ãMoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¡¡GetMoveEvent ¥á¥½¥Ã¥É¡£moveType ¤Çʬ´ô¤·¡¢UnityActon<Transform, float> ·¿¤ÇÃͤ¬Ìá¤ë¡ä
public UnityAction<Transform, float> GetMoveEvent(MoveType moveType) {
¡¡¡¡switch (moveType) {
    ¡¡¡¡case MoveType.Straight:
        ¡¡¡¡return MoveStraight;
        case MoveType.Meandering:
            return MoveMeandering;
        case MoveType.Boss_Horizontal:
            return MoveBossHorizontal;
        default:
            return Stop;
    }
}

¡¡¡¡¢­¡¡±¦ÊդνèÍý¤¬½ªÎ»¤¹¤ë¤È¡¢¥¨¥Í¥ß¡¼¤Î moveType ¤Ë±þ¤¸¤¿°ÜÆ°ÍѤΥ᥽¥Ã¥É¤¬£±¤Ä¤À¤±Ìá¤êÃͤȤ·¤Æ¼èÆÀ¤Ç¤­¤ë

¡ãEnemyController.cs¡ä
  // MoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î GetMoveEvent ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¡¢Ìá¤êÃͤǰÜÆ°ÍѤΥ᥽¥Ã¥É¤ò¼õ¤±¼è¤ë¡£¤³¤³¤Ç°ÜÆ°ÊýË¡¤ò·èÄê
¡¡// ¤É¤Á¤é¤â UnityAction<Transform, float> ¤Ç¤¢¤ë¤Î¤Ç¡¢ÂåÆþ¤¬À®Î©¤¹¤ë
  moveEvent = UnityAction<Transform, float> ·¿¤Î¥á¥½¥Ã¥É¤¬£±¤ÄÌá¤Ã¤Æ¤¯¤ë

¡¡¡¡¢­¡¡moveEvent ÊÑ¿ô¤Ë¤Ï°ÜÆ°ÍѤΥ᥽¥Ã¥É¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¤Î¤Ç¡¢Invoke ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¤Æ½èÍý¤ò¤¹¤ë
  // Invoke ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤È¡¢moveEvent ÊÑ¿ô¤ËÅÐÏ¿¤µ¤ì¤¿¥á¥½¥Ã¥É(º£²ó¤Ï°ÜÆ°ÍѤΥ᥽¥Ã¥É)¤ò¼Â¹Ô¤¹¤ë¡£UnityActon <Transform, float>·¿¤Ê¤Î¤Ç¡¢¼Â¹Ô¤Ë¤¢¤¿¤Ã¤Æ¡¢»ØÄꤵ¤ì¤¿·¿¤Î¾ðÊó¤ò»ØÄꤹ¤ë
  moveEvent.Invoke(transform, enemyData.moveDuration);

¡¡ÊÑ¿ô¤ÎÃæ¤Ë¥á¥½¥Ã¥É¤¬ÅÐÏ¿¤Ç¤­¤ë¡¢¤È¤¤¤¦¤Î¤ÏÉԻ׵Ĥ˻פ¨¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¤¬¡¢°ÊÁ°¤«¤é¤³¤ì¤Ë¶á¤¤½èÍý¤Ï¼ÂÁõ¤·¤Æ¤¤¤Þ¤¹¡£
Button ¥¯¥é¥¹¤Î AddListener ¥á¥½¥Ã¥É¤¬¤³¤ì¤ËÅö¤¿¤ê¤Þ¤¹¡£°ú¿ô¤Ë¡¢¥Ü¥¿¥ó¤ò²¡¤·¤¿ºÝ¤Ë¼Â¹Ô¤·¤¿¤¤¥á¥½¥Ã¥É¤òÅÐÏ¿¤·¤Æ¤¤¤¿¤Ï¤º¤Ç¤¹¡£



¡¡º£²ó¤Î UnityAction ¤Îµ¡Ç½¤Ç¥Ý¥¤¥ó¥È¤È¤Ê¤ë¤Î¤Ï¡¢°ÜÆ°ÍѤΥ᥽¥Ã¥É¤ËÂФ·¤ÆɬÍפʰú¿ô¤Î¾ðÊó¤ò·¿¥Ñ¥é¥á¡¼¥¿¤È¤¤¤¦·Á¤Ç»ØÄꤷ¤Æ¤¤¤ë¤³¤È¤Ç¤¹¡£
UnityAction<Transform, float> ·¿¤È¤Ï¡¢¤¹¤Ù¤Æ¤Î°ÜÆ°ÍѤΥ᥽¥Ã¥É¤Ç»ÈÍѤ¹¤ë°ú¿ô¤Î·¿¤ò»ØÄꤷ¤Æ¤¤¤ë¤³¤È¤¬Ê¬¤«¤ê¤Þ¤¹¡£

¡¡³Îǧ¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£

¡ãMoveEventSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¡ä
    public void MoveStraight(Transform tran, float duration) {
        //Debug.Log(tran);
        Debug.Log("ľ¿Ê");

        tran.DOLocalMoveY(moveLimit, duration);
    }

¡¡¥Ç¥ê¥²¡¼¥È¤Ë¤ÏÊ£¿ô¤Î¥á¥½¥Ã¥É¤òÅÐÏ¿¤·¤Æ½çÈ֤˼¹Ԥ¹¤ë¤È¤¤¤¦µ¡Ç½¤â¤¢¤ê¤Þ¤¹¤·¡¢¼Â¹Ô¤¹¤ë¥¿¥¤¥ß¥ó¥°¤ò¼«Ê¬¤ÇÀßÄê¤Ç¤­¤ë¤Î¤Ç¡¢³èÍѤǤ­¤ë¤ÈÊØÍø¤Êµ¡Ç½¤Ë¤Ê¤ê¤Þ¤¹¡£
¾¯¤·¤º¤Ä³Ð¤¨¤Æ¤¤¤­¤Þ¤·¤ç¤¦¡£¡¡


£´¡¥¥²¡¼¥à¤ò¼Â¹Ô¤·¤ÆÆ°ºî¤ò³Îǧ¤¹¤ë


¡¡¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤ò¤ª¤³¤Ê¤Ã¤¿¤Î¤Ç¡¢¥²¡¼¥à¾å¤Îµ¡Ç½¤Ï²¿¤âÊѤï¤ê¤Þ¤»¤ó¡£
¤½¤Î¤¿¤á¡¢¤³¤Î½èÍý¤ò¼Â¹Ô¤·¤¿ºÝ¤Ë¡¢º£¤Þ¤Ç¤ÈƱ¤¸¤è¤¦¤ËÆ°¤¯¤³¤È¤¬ÂçÀڤǤ¹¡£

¡¡¤â¤·¤â°ÊÁ°¤Î¤è¤¦¤Ë¾å¼ê¤¯°ÜÆ°¤¬µ¡Ç½¤·¤Ê¤¤¤Î¤Ç¤¢¤ì¤Ð¡¢¤½¤ì¤Ï¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤ÎºÝ¤Ëµ­½Ò¸í¤ê¤¬¤¢¤ê¤Þ¤¹¡£
½èÍý¤ò£±¤Ä¤º¤Ä½çÈÖ¤ËÄɤäƤ¤¤Ã¤Æ¡¢¤É¤ÎÉôʬ¤ÇÀµ¾ï¤ËÆ°¤¤¤Æ¤¤¤Ê¤¤¤«¤òÆÃÄꤷ¡¢¥¨¥é¡¼²Õ½ê¤òõ¤·¤Æ½¤Àµ¤·¤Æ¤¯¤À¤µ¤¤¡£


£µ¡¥¡ã¼Ø¹Ô½èÍý¤ÎÊä­¡ä


¡¡¼Ø¹Ô°ÜÆ°¤Î½èÍý¤Ë¤Ä¤¤¤ÆÊä­ÀâÌÀ¤·¤Þ¤¹¡£

    private void MoveMeandering(UnityEngine.Transform tran, float duration)
    {
        Debug.Log("¼Ø¹Ô");

        tran.DOLocalMoveX(tran.position.x + 150, 1f).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.Linear);  //<= ¤³¤³¡£DOLocalMoveX(tran.position.x + 150, 1f)¤ÇÆ°¤¯µ÷Î¥¤Ï¸ÇÄꤷ¤Æ¤¤¤ë
        tran.DOLocalMoveY(moveLimit, duration);
    }

¡¡¥½¡¼¥¹¥³¡¼¥É¤Ç¤Ïº¸±¦¤Î°ÜÆ°Éý¤Ï¸ÇÄꤷ¤Æ¤¤¤ë¤Ï¤º¤Ç¤¹¤¬¡¢¥²¡¼¥à¤ò¼Â¹Ô¤¹¤ë¤È¡¢Æ±¤¸Å¨¤Ç¤¢¤Ã¤Æ¤â°Û¤Ê¤ë°ÜÆ°Éý¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£


¡ã¸¡¾ÚÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯


¡¡¤³¤Î½èÍý¤ÏÆ°¤¤¤Æ¤Ï¤¤¤Þ¤¹¤¬¡¢¼Â¤Ï¡¢DOTween ¤ÎÂè1°ú¿ô¤ËÂФ·¤Æ¡¢Àµ¤·¤¯¤Ê¤¤»ØÄê¤ò¤ï¤¶¤È¤·¤Æ¤¤¤ë½èÍý¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡
¡¡DOTween ¤ÇÍøÍѤ·¤Æ¤¤¤ë¥á¥½¥Ã¥É¤Ï¡¢DOLocalMoveX ¥á¥½¥Ã¥É¤Ç¤¹¡£
¤½¤Î¤¿¤á¡¢ËÜÍè¤Ç¤¢¤ì¤ÐÂè1°ú¿ô¤Ë¤Ï¡¢°ÜÆ°¤µ¤»¤¿¤¤¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î LocalPosition ¤ò»ØÄꤹ¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¤³¤ì¤ÏÍøÍѤ¹¤ëDOTween ¤Î¥á¥½¥Ã¥É¤Ë¤è¤ê¡¢°ú¿ô¤Î»ØÄ꤬·è¤Þ¤ë¤¿¤á¤Ç¤¹¡£

¡¡¥Ý¥¤¥ó¥È¤ÏÍøÍѤ·¤Æ¤¤¤ë¥á¥½¥Ã¥É¤È°ú¿ô¤Î»ØÄê¤Ç¤¹¡£
DOMove ¥á¥½¥Ã¥É¤Ç¤¢¤ì¤ÐÂè1°ú¿ô¤Ï¥ï¡¼¥ë¥ÉºÂɸ(Ä̾ï¤Î Position) ¤ò»ØÄꤷ¤Þ¤¹¡£
¤¿¤À¤·¡¢DOLocalMove ¥á¥½¥Ã¥É¤Î¤è¤¦¤Ë¡¢Local ¤Îñ¸ì¤¬¥á¥½¥Ã¥É¤Ë¤¢¤ì¤Ð¡¢Âè1°ú¿ô¤Ë¤Ï¥í¡¼¥«¥ëºÂɸ(localPosition) ¤ò»ØÄꤹ¤ë¤³¤È¤Ç¡¢ËÜÍè¤ÎÀµ¤·¤¤½èÍý¤Ë¤Ê¤ê¤Þ¤¹¡£
¤³¤ì¤Ï¾¤Î DOTween ¤Î¾ì¹ç¤âƱÍͤǤ¹¡£Ì¾Á°¤ò¥Ò¥ó¥È¤Ë¡¢ÍøÍѤ¹¤ë°ú¿ô¤¬ÊѤï¤ê¤Þ¤¹¡£

¡¡¤Ç¤¹¤¬º£²ó¤Ï¡¢tran.position ¤Î·Á¤Ç¡¢Local ¤Ç¤Ï¤Ê¤¯¡¢¥ï¡¼¥ë¥ÉºÂɸ¤Ç¤Î Position ¤ò»ØÄꤷ¤Æ¤¤¤Þ¤¹¡£

tran.DOLocalMoveX(tran.position.x + 150, 1f).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.Linear);

¡¡¤½¤Î¤¿¤á¡¢·×»»¤¬¤¦¤Þ¤¯¤¤¤«¤º¡¢°ÜÆ°¤ÎÉý¤¬¤½¤ÎÅÔÅÙ¡¢¤Á¤°¤Ï¤°¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£

¡¡¤¿¤À¤·¡¢°ÜÆ°¼«ÂΤϤ¹¤ë¤Î¤È¡¢µ¬Â§À­¤Î¤Ê¤µ¤¬Å¨¤Î°ÜÆ°¤Ã¤Ý¤¯¤Æ¤¤¤¤¤È´¶¤¸¤¿¤Î¤Ç
º£²ó¤Ï¤³¤ì¤ò¡¢Å¨¤Î¥é¥ó¥À¥àÀ­¤È¤¤¤¦Éôʬ¤ÇÍøÍѤ·¤è¤¦¤È¤·¤Æ¡¢¤½¤Î¤Þ¤Þ¤ï¤¶¤ÈÀµ¤·¤¯¤Ê¤¤»ØÄê¤ò¤·¤Æ¤¤¤Þ¤¹¡£



¡¡°Ê¾å¤Î¤³¤È¤«¤é¡¢¥×¥í¥°¥é¥àÆâ¤ÇÄê¿ô¤Ç°ÜÆ°Éý¤ò¤·¤Æ¤¤¤ë¤Î¤Ë¡¢°ÜÆ°Éý¤¬¸ÇÄê¤Ç¤Ï¤Ê¤¯¤Ê¤¼ÊѤï¤ë¤Î¤«¡©¡¡¤È¤¤¤¦¤È
¡Ö°ú¿ô¤Î»ØÄêÀ褬Àµ¤·¤¯¤Ê¤¤¤¿¤á¡¢Ëè²ó¡¢ÉÔ°ÂÄê¤ÊµóÆ°¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡×¤È¤¤¤¦¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

¡¡²¼µ­¤Î¤è¤¦¤Ë DOLocalMoveX ¥á¥½¥Ã¥É¤ÎÂè1°ú¿ô¤òÀµ¤·¤¤»ØÄêÀè¤Ë½¤Àµ¤¹¤ë¤³¤È¤Ç¡¢Ëè²ó¡¢Æ±¤¸Éý¤À¤±¤ò°ÜÆ°¤¹¤ë½èÍý¤Ë¤Ê¤ê¤Þ¤¹¡£

tran.DOLocalMoveX(tran.localPosition.x + 150, 1f).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.Linear);


£¶¡¥¡ãDOAnchorPos ¥á¥½¥Ã¥É¡ä


¡¡´ðËÜŪ¤Ë Canvas Æâ¤Ç¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Î°ÜÆ°¤Ï¡¢¾ï¤Ë Canvas ¤«¡¢¤¢¤ë¤¤¤Ï¾¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Î»Ò¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤â¤Î¤òÆ°¤«¤¹²ÄǽÀ­¤¬¹â¤¤¤Î¤Ç¡¢
¿Æ¤«¤é¤ß¤¿ºÂɸ¤ÇÁêÂÐŪ¤Ë°ÜÆ°¤¬¤Ç¤­¤ë Local ¤òÍøÍѤ¹¤ë¤Î¤¬Àµ¤·¤¤¤Ç¤¹¤·¡¢¤½¤¦¤¹¤ë¤³¤È¤Ç¤¹¤Ù¤ÆƱ¤¸µóÆ°¤Ë¤Ê¤ê¤Þ¤¹¡£

¡¡¤Þ¤¿¡¢Canvas ¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ï Anchor ¤Î°ÌÃ֤ˤè¤Ã¤Æ¥ª¥Ö¥¸¥§¥¯¥È¤Î°ÌÃÖ¤¬ÀßÄꤵ¤ì¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢¥¢¥ó¥«¡¼¤¬Ãæ±ûÃÍ(Middle¡¢Center) ¤Ç¤Ê¤¤¾ì¹ç¡¢DOLocalMove ¤Ç°ÜÆ°¤µ¤»¤ë¤Èͽ´ü¤·¤Ê¤¤Êý¸þ¤Ø°ÜÆ°¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£

¡¡¤³¤ì¤ò²óÈò¤¹¤ë¤¿¤á¡¢DOTween ¤Ë¤Ï DOAnchorPos ¤È¤¤¤¦¡¢UI ÍѤΰÜÆ°¤Î¥á¥½¥Ã¥É¤¬ÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤³¤Á¤é¤òÍøÍѤ¹¤ë¤â¤Î£±¤Ä¤ÎÊýË¡¤Ç¤¹¡£¤³¤Á¤é¤â DOMove ¤ÈƱ¤¸¤Ç¡¢3¼´¤Þ¤È¤á¤ÆÆ°¤«¤¹¥á¥½¥Ã¥É¤È¡¢³Æ¼´¤ò»ØÄꤷ¤ÆÆ°¤«¤¹¥á¥½¥Ã¥É¤¬¤½¤ì¤¾¤ì¤¢¤ê¤Þ¤¹¡£

¡¡¤½¤Î¾ì¹ç¡¢¥á¥½¥Ã¥É¤ÎÌ¿ÎáÀè¤Ï Transform ¤Ç¤Ï¤Ê¤¯¤Æ¡¢RectTransform ¤ËÂФ·¤Æ¼Â¹ÔÌ¿Îá¤ò½Ð¤¹·Á¤Ë¤Ê¤ê¤Þ¤¹¡£
¤½¤ÎÂå¤ï¤ê¤Ë¡¢DOAnchorPos ¤Ç¤¢¤ì¤Ð¡¢Anchor ¤Î°ÌÃ֤˴ط¸¤Ê¤¯¡¢LocalPosition ¤Ç»ØÄꤷ¤¿°ÌÃÖ¤ËÀµ¤·¤¯°ÜÆ°¤Ç¤­¤Þ¤¹¡£

¡¡²¼µ­¤Î¤è¤¦¤ËÍøÍѤǤ­¤Þ¤¹¡£»î¤·¤Ë½ñ¤­´¹¤¨¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£

private void MoveMeandering(UnityEngine.Transform tran, float duration)
{
    Debug.Log("¼Ø¹Ô");

    // DOAnchorPosX¡¢DOAnchorPosY ¤Î¾ì¹ç
    RectTransform rectTran = tran.GetComponent<RectTransform>();
    rectTran.DOAnchorPosX(tran.localPosition.x + 150, 1f).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.Linear);
    rectTran.DOAnchorPosY(moveLimit, duration);
    
    // DOLocalMoveX ¤Î¾ì¹ç
    //tran.DOLocalMoveX(tran.localPosition.x + 150, 1f).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.Linear);
    //tran.DOLocalMoveY(moveLimit, duration);
}


¡ã½¤Àµ¸å¤ÎÆ°²è¡¡¡¼Æ±¤¸°ÜÆ°Éý¤Ë¸ÇÄê²½¤µ¤ì¤ë¡¼¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯


»²¹Í¥µ¥¤¥È
¸¶¥«¥Ð¥ó¤Ï³ó¤Î¤ªÅ¹¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£ ÍÍ
¡ÚUnity¡ÛDOTween¤ò»È¤Ã¤¿uGUI¥¢¥Ë¥á¡¼¥·¥ç¥ó
Zenn ¥ª¥ª¥Ð@ohbashunsuke ÍÍ
uGUI - RectTransform¤Î¥È¥¥¥¤¡¼¥ó¡Ã¡ÚUnity¡ÛDOTween¤Î¶µ²Ê½ñ¡Á¥¹¥¯¥ê¥×¥È¤Ç¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òÁà¤ë¥Ð¥¤¥Ö¥ë¡Á



¡¡°Ê¾å¤Ç¤³¤Î¼ê½ç¤Ï½ªÎ»¤Ç¤¹¡£

¡¡¼¡¤Ï¡¡È¯Å¸£±£²¡¡¥¨¥Í¥ß¡¼ÍѤΥХì¥Ã¥È¤ÎºîÀ®¤È¼«Æ°À¸À®½èÍý¤Î¼ÂÁõ¡Ý¡¡¤Ç¤¹¡£

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


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

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

Menu


´ðÁÃ

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

private



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

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