void Update()
    {
        if (controllerComponent == null)
        {
            return;
        }

        transform.position = controllerComponent.GetTransform().position;
        transform.rotation = controllerComponent.GetTransform().rotation;

        if (controllerComponent.IsGrabDown())
        {
            Instantiate(Item, transform.position, Quaternion.identity);
        }
    }
    private void SpawnRingR()
    {
        bool isSpawn = HasControllerR() && HasGameObject(m_Ring);

        if (!isSpawn)
        {
            return;
        }

        if (m_ControllerR.IsGrabDown())
        {
            Vector3    pos   = m_ControllerR.GetTransform().position;
            Quaternion rot   = m_ControllerR.GetTransform().rotation;
            GrabObject lasso = Instantiate(m_Ring, pos, rot).GetComponent <GrabObject>();
            lasso.AttachController(m_ControllerObjectR);
        }
    }
Beispiel #3
0
    /// <summary>
    /// ジョイントをアタッチする
    /// </summary>
    /// <param name="objcet"></param>
    private void AttachFixedJoint()
    {
        FixedJoint joint;
        Rigidbody  rigidbody;

        if (!HasController())
        {
            return;
        }

        MyController controller = m_controller.GetComponent <MyController>();

        if (controller == null)
        {
            return;
        }

        if (controller.GetGrabNum() != 0)
        {
            return;
        }

        if ((joint = GetComponent <FixedJoint>()) == null)
        {
            joint = gameObject.AddComponent <FixedJoint>();
        }

        if (joint.connectedBody != null)
        {
            return;
        }

        if ((rigidbody = m_controller.GetComponent <Rigidbody>()) == null)
        {
            rigidbody = m_controller.AddComponent <Rigidbody>(); //柔軟
        }

        transform.position  = controller.GetTransform().position;
        joint.connectedBody = rigidbody;
    }