Moved Permanently to https://vrm.dev/en/

VRM - humanoid 3d avatar format for VR
  •  VRMFirstPersonの使い方(ja)
  • How to Use VRMFirstPerson

    VRMFirstPerson Settings

    VRMFirstPerson has the following settings for Renderer:

    FirstPersonFlag Layer Note
    Both default Specify parts that are not necessarily separated between first-person view and third-person view.
    ThirdPersonOnly THIRDPERSON_ONLY_LAYER Specify parts that are not rendered in first-person view.
    FirstPersonOnly FIRSTPERSON_ONLY_LAYER Specify parts that are not rendered in third-person view. The auto-created headless model is used.
    Auto THIRDPERSON_ONLY_LAYER Automatically create the model in first-person view at runtime and set it to FIRSTPERSON_ONLY_LAYER.

    By calling VRMFirstPerson.Setup at runtime, the layer settings described above can be performed. Please call the function explicitly from outside.

    Specify the additional render layers for the application

    The following layers are defined as constant:

    public class VRMFirstPerson : MonoBehaviour
    {
        public const int FIRSTPERSON_ONLY_LAYER = 9;
        public const int THIRDPERSON_ONLY_LAYER = 10;
    
        // The following parts are omitted
    }
    Set Layer in #9 and #10

    Call Setup function at runtime and set LayerMask in Camera

    • Call VRMFirstPerson.Setup
    • Set LayerMask for first-person camera view and other camera views
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using VRM;
    
    public class SetupExample : MonoBehaviour
    {
        [SerializeField]
        Camera m_firstPersonCamera; // HMD camera
        
        [SerializeField]
        LayerMask m_firstPersonMask; // Set a first-person mask (default | FIRSTPERSON_ONLY_LAYER, etc.) in HMD camera
    
        [SerializeField]
        LayerMask m_otherMask; // Set other masks (default | THIRDPERSON_ONLY_LAYER, etc.) in HMD camera
    
        [SerializeField]
        VRMFirstPerson m_firstPerson;
    
        void Reset()
        {
            m_firstPerson = GameObject.FindObjectOfType<VRMFirstPerson>();
        }
    
        void Start()
        {
            foreach (var camera in GameObject.FindObjectsOfType<Camera>())
            {
                camera.cullingMask = (camera == m_firstPersonCamera)
                    ? m_firstPersonMask
                    : m_otherMask
                    ;
            }
    
            // VRMFirstPerson initialization
            if (m_firstPerson != null)
            {
                m_firstPerson.Setup();
            }
        }
    }
    VRM - humanoid 3d avatar format for VR