コード例 #1
0
 /// <summary> Setup the SG_BasicFeedback script components  </summary>
 public virtual void SetupSelf()
 {
     SG_Util.TryAddRB(this.gameObject, false, true);
     cooldownTimer = 0;
     SetTrackingTarget(this.trackingTarget, true); //updates offsets on start
     this.lastPosition = this.transform.position;
 }
コード例 #2
0
        //-------------------------------------------------------------------------------------------------------------------------------------------
        // Functions

        /// <summary> Setup the SG_BasicFeedback script components  </summary>
        public virtual void SetupSelf()
        {
            //Debug.Log(this.name + "Calculated Offsets!");
            SG_Util.TryAddRB(this.gameObject, false, true);
            cooldownTimer = 0;
            SetTrackingTarget(this.trackingTarget, true); //updates offsets on start
            this.lastPosition = this.transform.position;

            if (this.linkedGlove == null && this.feedbackScript != null && this.feedbackScript.TrackedHand != null)
            {
                this.linkedGlove = this.feedbackScript.TrackedHand.gloveHardware;
            }
        }
コード例 #3
0
 /// <summary> Try to add a rigidbody to this GameObject, if one isn't already present </summary>
 /// <param name="useGrav"></param>
 /// <param name="isKinematic"></param>
 public void TryAddRB(bool useGrav = false, bool isKinematic = false)
 {
     this.physicsBody = SG_Util.TryAddRB(this.gameObject, useGrav, isKinematic);
 }
コード例 #4
0
    /// <summary> Setup and/or change the tracking variables of this hand. </summary>
    /// <param name="newTarget"></param>
    /// <param name="trackType"></param>
    /// <param name="trackMethod"></param>
    /// <param name="rightHand"></param>
    protected virtual void SetupTracking(Transform newTarget, TrackingHardware trackType, TrackingMethod trackMethod, bool rightHand)
    {
        this.trackedObject    = newTarget;
        this.trackingHardware = trackType;
        this.trackingMethod   = trackMethod;

        //Calculate appropriate offsets
        if (trackedObject != null)
        {
            if (trackingHardware != TrackingHardware.Custom)
            {
                int        LR      = rightHand ? 1 : -1;
                Vector3    posOffs = Vector3.zero;
                Quaternion rotOffs = Quaternion.identity;
                if (trackingHardware == TrackingHardware.ViveTracker)
                {
                    posOffs = new Vector3(0.01f * LR, 0.04f, -0.085f);
                    rotOffs = Quaternion.Euler(0, -90, -90);
                    Debug.Log("Setting up right hand for Vive Tracker");
                }
                this.positionOffset = posOffs;
                this.rotationOffset = rotOffs;
            }
            else
            {
                SG_Util.CalculateOffsets(this.transform, this.trackedObject, out this.positionOffset, out this.rotationOffset);
            }
        }

        //Ignore collisions of the hand itself
        if (this.rigidBodyLayer != null)
        {
            if (this.physicsTrackingLayer != null)
            {
                this.rigidBodyLayer.SetIgnoreCollision(this.physicsTrackingLayer, true);
            }
            if (this.feedbackScript != null)
            {
                this.feedbackScript.SetIgnoreCollision(this.rigidBodyLayer, true);
            }
        }
        if (this.feedbackScript != null && this.physicsTrackingLayer != null)
        {
            this.feedbackScript.SetIgnoreCollision(this.physicsTrackingLayer, true);
        }

        //Apply the appropriate RB method
        if (trackingMethod == TrackingMethod.PhysicsBased && physicsTrackingLayer != null)
        {
            physicsTrackingLayer.RemoveRigidBodies();
            this.handRB     = SG_Util.TryAddRB(this.gameObject, false, false);
            ignoreGrabables = true;
            if (physicsTrackingLayer != null)
            {
                physicsTrackingLayer.gameObject.SetActive(true);
            }
        }
        else
        {
            ignoreGrabables = false;
            SG_Util.TryRemoveRB(this.gameObject); //should prevent calling OnCollisionEnter
            this.handRB = null;
            if (physicsTrackingLayer != null)
            {
                physicsTrackingLayer.gameObject.SetActive(false);
            }
        }
    }
コード例 #5
0
 protected override void Awake()
 {
     base.Awake();
     SG_Util.TryAddRB(this.gameObject, false, true);
 }