ºÇ½ª¹¹¿·¡§ orika_ex_miyako 2023ǯ05·î21Æü(Æü) 16:16:09ÍúÎò
¡¡TPS ¥²¡¼¥à¤ÎÀ©ºî¤Ë Cinemachine ¤òÍøÍѤ¹¤ë¤³¤È¤Ç¡¢¤¤¤¯¤Ä¤«¤ÎÊýË¡¤Ç TPS ÍѤΥ«¥á¥é¤¬À©¸æ¤Ç¤¤Þ¤¹¡£
¡¡¤½¤Î¤¦¤Á¡¢Cinemachine FreeLook Camera¤Ï¡¢¥¥ã¥é¥¯¥¿¡¼¤Î¿Ê¹ÔÊý¸þ¤ËÂФ·¤Æ¥«¥á¥é¤¬¼«Æ°Åª¤Ë°ÜÆ°¤·¡¢
¥¥ã¥é¥¯¥¿¡¼¤Î¼þ¤ê¤ò360ÅÙ¼«Í³¤ËÆ°¤«¤»¤ë¥«¥á¥é(Orbital Transposer)¤Ç¤¹¡£
¡¡¤¿¤À¤·¡¢Y¼´¤Î²óž¤¬À©¸Â¤Ê¤¯¹Ô¤ï¤ì¤ë¤¿¤á¡¢¥«¥á¥é¤¬°Õ¿Þ¤·¤Ê¤¤°ÌÃ֤˰ÜÆ°¤¹¤ë²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£
¡¡¤³¤ì¤ò²ò¾Ã¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¥¹¥¯¥ê¥×¥È¤ÇY¼´¤Î²óž¤òÀ©¸æ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¡¡²¼µ¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤òÄ󼨤·¤Þ¤¹¡£
¡¡
using System.Collections; using System.Collections.Generic; using UnityEngine; using Cinemachine; public class LimitYRotation : MonoBehaviour { [SerializeField] private CinemachineFreeLook freeLookCam; [SerializeField] private float minYAngle = -45f; // ºÇ¾®Y³ÑÅÙ [SerializeField] private float maxYAngle = 45f; // ºÇÂçY³ÑÅÙ private void Update() { LimitFreeLookYAxis(); } /// <summary> /// Y ¼´Êý¸þ¤Î²óžÀ©¸æ /// </summary> private void LimitFreeLookYAxis() { // Y¼´¤Î³ÑÅÙ¤ò¼èÆÀ float currentYAngle = freeLookCam.m_YAxis.Value * 180f; // Y¼´¤Î³ÑÅÙ¤¬À©¸Â¤òĶ¤¨¤Æ¤¤¤¿¤é½¤Àµ if (currentYAngle < minYAngle) { freeLookCam.m_YAxis.Value = minYAngle / 180f; } else if (currentYAngle > maxYAngle) { freeLookCam.m_YAxis.Value = maxYAngle / 180f; } } }
¡¡¤³¤Î¥¹¥¯¥ê¥×¥È¤ò¿·µ¬¤ÎGameObject¤Ë¥¢¥¿¥Ã¥Á¤·¤ÆÍøÍѤ·¤Þ¤¹¡£
¤¢¤ë¤¤¤Ï¡¢Cinemachine ¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤âÌäÂꤢ¤ê¤Þ¤»¤ó¡£
¡¡freeLookCam ÊÑ¿ô¤Ë Cinemachine FreeLook Camera¤ò³ä¤êÅö¤Æ¤Æ¤¯¤À¤µ¤¤¡£
¤Þ¤¿¡¢minYAngle¤ÈmaxYAngle¤ÏÀ©¸Â¤·¤¿¤¤Y¼´¤Î³ÑÅÙ¤ò»ØÄꤷ¤Þ¤¹¡£
¡¡¤³¤Î¥¹¥¯¥ê¥×¥È¤Ï¡¢Ëè¥Õ¥ì¡¼¥à¤Î¹¹¿·¤ÇFreeLook Camera¤ÎY¼´¤Î³ÑÅÙ¤ò¥Á¥§¥Ã¥¯¤·¡¢ÀßÄꤵ¤ì¤¿ºÇ¾®ÃͤäºÇÂçÃͤòĶ¤¨¤Æ¤¤¤¿¤é¤½¤Î³ÑÅÙ¤ò½¤Àµ¤·¤Þ¤¹¡£
¡¡³ÑÅÙ¤ÏÅÙ¿ôË¡¤Ç¤Ï¤Ê¤¯¡¢UnityÆâÉô¤Ç»ÈÍѤµ¤ì¤ë[0, 1]¤ÎÈϰϤǴÉÍý¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢³ÑÅÙ¤òÅÙ¿ôË¡¤«¤é¤³¤ÎÈϰϤËÊÑ´¹¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡Ê180¤Ç½ü»»¤Þ¤¿¤Ï¾è»»¤·¤Æ¤¤¤ë¤Î¤Ï¤½¤Î¤¿¤á¤Ç¤¹¡Ë¡£
¡¡°Ê¾å¤Ë¤Ê¤ê¤Þ¤¹¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- ¥×¥í¥°¥é¥ß¥ó¥°
¥³¥á¥ó¥È¤ò¤«¤¯