Пример #1
0
    private IEnumerator Nudge(Vector2 direction)
    {
        _soundEngine.PlaySFX("bounce", true);
        var   startPos = transform.position;
        float progress = 0;
        float start    = Time.time;

        while (progress < Mathf.PI)
        {
            float time = Time.time - start;
            progress = time * nudgeSpeed;

            float x = (progress / Mathf.PI) * nudgeDistance;
            float y = Mathf.Sin(progress) * nudgeBounceHeight;

            transform.position = startPos + new Vector3(x * direction.x, y);
            yield return(new WaitForEndOfFrame());
        }

        transform.position = new Vector3(transform.position.x, startPos.y);
    }