Exemple #1
0
    /// <summary>
    /// Handles moving the key from is current position to the given destination
    /// using a parabola arc effect
    /// </summary>
    /// <param name="current"></param>
    /// <param name="destination"></param>
    /// <returns></returns>
    public IEnumerator MoveToDestinationRoutine(Vector3 current, Transform destination)
    {
        while (Vector3.Distance(m_parent.position, destination.position) > m_destinationProximity && !GameManager.instance.PlayerScript.IsDead)
        {
            m_animationTime += Time.deltaTime;
            m_animationTime  = m_animationTime % m_arcHeight;
            float time = m_animationTime / m_speed;

            Vector3 position = ParabolaEffect.Parabola(current, destination.position, m_arcHeight, time);
            m_parent.position = position;
            yield return(new WaitForEndOfFrame());
        }

        m_animationTime   = 0;
        m_parent.position = destination.position;
    }
 // Start is called before the first frame update
 void Start()
 {
     current = this;
 }