示例#1
0
        //paste a arrow to a rb
        private void StickToRigidBody(Rigidbody rb)
        {
            joint = gameObject.AddComponent <FixedJoint>();
            joint.connectedBody   = rb;
            joint.enableCollision = false;
            joint.breakForce      = float.MaxValue;
            joint.breakTorque     = float.MaxValue;
            joint.massScale       = MASS_SCALE;

            thisCollider.enabled = false;

            //notify the connection, so we can track the numbers of connections per rigidbody and avoid jittering
            ArrowConnections.Add(rb, this);

            stickToRB = true;
        }
示例#2
0
        private void OnGrabStateChange(GrabState state)
        {
            if (!grabProcessed && (state == GrabState.Grab || state == GrabState.Flying))
            {
                hitSomething  = true;
                grabProcessed = true;

                //if we have a joint destroy it
                Joint j = GetComponent <Joint>();

                if (j != null)
                {
                    ArrowConnections.Remove(j.connectedBody, this);
                    Destroy(j);
                }

                stickToRB = false;
            }
        }