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

Àß·×


¡¡TPS ¥²¡¼¥à¤ÎÀ©ºî¤Ë Cinemachine ¤òÍøÍѤ¹¤ë¤³¤È¤Ç¡¢¤¤¤¯¤Ä¤«¤ÎÊýË¡¤Ç TPS ÍѤΥ«¥á¥é¤¬À©¸æ¤Ç¤­¤Þ¤¹¡£

¡¡¤½¤Î¤¦¤Á¡¢Cinemachine FreeLook Camera¤Ï¡¢¥­¥ã¥é¥¯¥¿¡¼¤Î¿Ê¹ÔÊý¸þ¤ËÂФ·¤Æ¥«¥á¥é¤¬¼«Æ°Åª¤Ë°ÜÆ°¤·¡¢
¥­¥ã¥é¥¯¥¿¡¼¤Î¼þ¤ê¤ò360ÅÙ¼«Í³¤ËÆ°¤«¤»¤ë¥«¥á¥é(Orbital Transposer)¤Ç¤¹¡£

¡¡¤¿¤À¤·¡¢Y¼´¤Î²óž¤¬À©¸Â¤Ê¤¯¹Ô¤ï¤ì¤ë¤¿¤á¡¢¥«¥á¥é¤¬°Õ¿Þ¤·¤Ê¤¤°ÌÃ֤˰ÜÆ°¤¹¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£

¡¡¤³¤ì¤ò²ò¾Ã¤¹¤ë¤¿¤á¤Ë¤Ï¡¢¥¹¥¯¥ê¥×¥È¤ÇY¼´¤Î²óž¤òÀ©¸æ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£


LimitYRotation ¥¹¥¯¥ê¥×¥È¤òºîÀ®¤¹¤ë


¡¡²¼µ­¤Î¥µ¥ó¥×¥ë¥³¡¼¥É¤òÄ󼨤·¤Þ¤¹¡£
¡¡

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¤Ç½ü»»¤Þ¤¿¤Ï¾è»»¤·¤Æ¤¤¤ë¤Î¤Ï¤½¤Î¤¿¤á¤Ç¤¹¡Ë¡£



¡¡°Ê¾å¤Ë¤Ê¤ê¤Þ¤¹¡£

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


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

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

Menu


´ðÁÃ

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

private



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

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