Exemple #1
0
        void Start()
        {
            rb             = GetComponent <Rigidbody>();
            grabsInTrigger = GetComponent <GrabbablesInTrigger>();
            joint          = GetComponent <ConfigurableJoint>();
            input          = InputBridge.Instance;

            // Setup defaults
            if (joint == null)
            {
                joint = gameObject.AddComponent <ConfigurableJoint>();
                joint.rotationDriveMode = RotationDriveMode.Slerp;

                JointDrive slerpDrive = joint.slerpDrive;
                slerpDrive.positionSpring = 600;

                JointDrive xDrive = joint.xDrive;
                xDrive.positionSpring = 2500;
                JointDrive yDrive = joint.yDrive;
                yDrive.positionSpring = 2500;
                JointDrive zDrive = joint.zDrive;
                zDrive.positionSpring = 2500;
            }

            if (HandsGraphics)
            {
                handsGraphicsParent   = HandsGraphics.transform.parent;
                handsGraphicsPosition = HandsGraphics.transform.localPosition;
                handsGraphicsRotation = HandsGraphics.transform.localRotation;

                //handsGraphicsGrabberOffset = HandsGraphics.position - transform.position;
                handsGraphicsGrabberOffset         = transform.InverseTransformPoint(HandsGraphics.position);
                handsGraphicsGrabberOffsetRotation = transform.localEulerAngles;
            }

            // Make Collision Dynamic so we don't miss any collisions
            if (rb && rb.isKinematic)
            {
                rb.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
            }

            // Should we auto equip an item
            if (EquipGrabbableOnStart != null)
            {
                GrabGrabbable(EquipGrabbableOnStart);
            }

            // Velocity Tracking
            if (velocityTracker == null)
            {
                velocityTracker = GetComponent <VelocityTracker>();
            }

            // Add Velocity Tracker if one was not provided
            if (velocityTracker == null)
            {
                velocityTracker = gameObject.AddComponent <VelocityTracker>();
                velocityTracker.controllerHand = HandSide;
            }
        }
Exemple #2
0
        void requestOwnerShipForNearbyGrabbables(GrabbablesInTrigger grabbables)
        {
            if (grabbables == null)
            {
                return;
            }

            // In Hand
            foreach (var grab in grabbables.NearbyGrabbables)
            {
                PhotonView view = grab.Value.GetComponent <PhotonView>();

                if (view != null && RecentlyRequested(view) == false && !view.AmOwner)
                {
                    RequestGrabbableOwnership(view);
                }
            }

            // Remote Grabbables
            foreach (var grab in grabbables.ValidRemoteGrabbables)
            {
                PhotonView view = grab.Value.GetComponent <PhotonView>();

                if (view != null && RecentlyRequested(view) == false && !view.AmOwner)
                {
                    RequestGrabbableOwnership(view);
                }
            }
        }
Exemple #3
0
        void Start()
        {
            LeftGrabber = GameObject.Find("LeftController").GetComponentInChildren <Grabber>();
            gitLeft     = LeftGrabber.GetComponent <GrabbablesInTrigger>();

            RightGrabber = GameObject.Find("RightController").GetComponentInChildren <Grabber>();
            gitRight     = RightGrabber.GetComponent <GrabbablesInTrigger>();

            requestedGrabbables = new Dictionary <int, double>();
        }
Exemple #4
0
        // Start is called before the first frame update
        void Start()
        {
            gZone = GetComponent <GrabbablesInTrigger>();

            // Auto Equip item
            if (HeldItem != null)
            {
                GrabGrabbable(HeldItem);
            }
        }
Exemple #5
0
        void Start()
        {
            rb             = GetComponent <Rigidbody>();
            grabsInTrigger = GetComponent <GrabbablesInTrigger>();
            joint          = GetComponent <ConfigurableJoint>();
            // Setup defaults
            if (joint == null)
            {
                joint = gameObject.AddComponent <ConfigurableJoint>();
                joint.rotationDriveMode = RotationDriveMode.Slerp;

                JointDrive slerpDrive = joint.slerpDrive;
                slerpDrive.positionSpring = 600;

                JointDrive xDrive = joint.xDrive;
                xDrive.positionSpring = 2500;
                JointDrive yDrive = joint.yDrive;
                yDrive.positionSpring = 2500;
                JointDrive zDrive = joint.zDrive;
                zDrive.positionSpring = 2500;
            }

            // Look for input from Player
            if (GameObject.FindGameObjectWithTag("Player"))
            {
                input = GameObject.FindGameObjectWithTag("Player").GetComponent <InputBridge>();
            }

            if (HandsGraphics)
            {
                handsGraphicsParent   = HandsGraphics.transform.parent;
                handsGraphicsPosition = HandsGraphics.transform.localPosition;
                handsGraphicsRotation = HandsGraphics.transform.localRotation;
            }

            playSpace                 = GameObject.Find("TrackingSpace");
            previousVelocities        = new List <Vector3>();
            previousAngularVelocities = new List <Vector3>();

            // Make Collision Dynamic so we don't miss any collisions
            if (rb && rb.isKinematic)
            {
                rb.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative;
            }

            // Should we auto equip an item
            if (EquipGrabbableOnStart != null)
            {
                GrabGrabbable(EquipGrabbableOnStart);
            }
        }
Exemple #6
0
 private void GetReferences()
 {
     gZone            = GetComponent <GrabbablesInTrigger>();
     snapConditions   = GetComponents <ISnapCondition>();
     unsnapConditions = GetComponents <IUnSnapCondition>();
 }
Exemple #7
0
 void Start()
 {
     ringCanvas       = GetComponent <CanvasScaler>();
     ringText         = GetComponent <Text>();
     nearbyGrabbables = Snap.GetComponent <GrabbablesInTrigger>();
 }