Example #1
0
    private void SuckCollectableIn(ICollectable collectable)
    {
        var collectableRigidbody = collectable.GetRigidbody();
        var distance             = gameObject.transform.position - collectableRigidbody.position;
        var suckDirection        = distance.normalized;
        var interpolation        = distance.magnitude / _sphereCollider.radius;

        collectableRigidbody.velocity = suckDirection * Mathf.Lerp(suckSpeed, 0, interpolation);
    }
Example #2
0
    private void CollectIfNearEnough(ICollectable collectable)
    {
        var distance = gameObject.transform.position - collectable.GetRigidbody().position;

        if (distance.magnitude <= collectionRange)
        {
            _collectablesInSuckRange.Remove(collectable);
            collectable.OnCollect();
            inventory.Store(collectable);
            collectionSound.Play();
        }
    }