示例#1
0
 void Update()
 {
     if (triggerScript.GetContact())
     {
         if (timer >= 0f)
         {
             timer -= Time.deltaTime;
         }
         else
         {
             foreach (Rigidbody rb in allChildren)
             {
                 Vector3 vel = rb.angularVelocity;
                 if (vel.magnitude > maxVel)
                 {
                     triggerScript.PlayRandomAudio(rb.position);
                     timer = timerVal;
                     break;
                 }
             }
         }
     }
 }
    void tossObject(Rigidbody rigidBody)
    {
        // Toss an object
        if (rigidBody == null)
        {
            return;
        }

        // Play a whoosh sound
        triggerScript.PlayRandomAudio(transform.position);

        Transform origin = trackedObject.origin ? trackedObject.origin : trackedObject.transform.parent;

        if (origin != null)
        {
            rigidBody.velocity        = origin.TransformVector(device.velocity);
            rigidBody.angularVelocity = origin.TransformVector(device.angularVelocity);
        }
        else
        {
            rigidBody.velocity        = device.velocity;
            rigidBody.angularVelocity = device.angularVelocity;
        }
    }