Beispiel #1
0
    IEnumerator DampVelocity(Rigidbody target, Collider other)
    {
        Debug.Log("Slowing down!");
        do
        {
            // Here we are damping (simply multiplying) velocity of the sphere whith each frame, until it reaches our threshold
            target.velocity *= dampingFactor;
            yield return(new WaitForEndOfFrame());
        } while (target.velocity.magnitude > dampingThreshold);

        // Completely stop momentum
        target.velocity    = Vector3.zero;
        prototype.isMoving = false;
        Debug.Log("Landed!");
        yield return(new WaitForSeconds(waitAtTarget));

        prototype.iterateTarget();
    }