예제 #1
0
    void OnParticleCollision(GameObject other)
    {
        int      numCollisionEvents = part.GetCollisionEvents(other, collisionEvents);
        IRagdoll ragdoll            = other.GetComponent <IRagdoll> ();

        if (ragdoll != null)
        {
            if (!ragdoll.GetIsRagdolled())
            {
                ragdoll.Ragdoll(true, Vector3.zero);
            }
        }

        Rigidbody rb = other.GetComponent <Rigidbody> ();

        for (int i = 0; i < collisionEvents.Count; i++)
        {
            if (ragdoll != null && rb != null)
            {
                Vector3 force = collisionEvents[i].velocity / 5;
                ragdoll.ApplyVelocityToBones(force);
            }
            else if (rb != null)
            {
                Vector3 pos   = collisionEvents[i].intersection;
                Vector3 force = collisionEvents[i].velocity;
                rb.AddForce(force);
            }
        }
    }
예제 #2
0
    private void OnTriggerEnter(Collider other)
    {
        IRagdoll  ragdoll = other.GetComponent <IRagdoll> ();
        Rigidbody rb      = other.GetComponent <Rigidbody>();
        Vector3   newDir  = transform.up;

        if (ragdoll != null)
        {
            ragdoll?.Ragdoll(true, newDir * velocity);
            ragdoll.ApplyVelocityToBones(newDir * velocity);
        }
        else if (rb != null)
        {
            rb.velocity = new Vector3(rb.velocity.x, 0, rb.velocity.y) + (newDir * velocity);
        }
    }
 public void Throw(Vector3 dir)
 {
     if (grabbedObject != null)
     {
         Grabbable toThrow = grabbedObject;
         ReachOut(false);
         IRagdoll ragdoll = toThrow.GetComponent <IRagdoll> ();
         if (ragdoll != null)
         {
             ragdoll.ApplyVelocityToBones(dir * throwSpeed);
         }
         else
         {
             toThrow.rb.velocity = dir * throwSpeed;
         }
         canGrab = false;
         Invoke("EnableGrab", grabResetTime);
     }
 }