예제 #1
0
    public static IEnumerator ArcPutDown(Transform fromPos, GenericInteraction inter, float dur)
    {
        float      counter  = 0;
        Quaternion q        = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0);
        Vector3    toPos    = inter.GetCell().transform.position;
        Vector3    start    = fromPos.position;
        Vector3    arc      = start + (toPos - start) / 2 + Vector3.up * .5f;
        float      distance = Vector3.Distance(fromPos.position, toPos); //distance - vel=distance/time
        float      time     = distance / dur;

        while (counter < dur)
        {
            counter += Time.deltaTime;
            toPos    = inter.GetCell().transform.position;
            Vector3 m1 = Vector3.Lerp(start, arc, counter / dur);
            Vector3 m2 = Vector3.Lerp(arc, toPos, counter / dur);
            fromPos.position = Vector3.Lerp(m1, m2, counter / dur);
            fromPos.rotation = Quaternion.Slerp(fromPos.rotation, q, counter / dur);
            yield return(null);
        }
    }
예제 #2
0
    public static IEnumerator ArcPickUp(Transform fromPos, GenericInteraction inter, float dur)
    {
        float counter = 0;

        fromPos.rotation = guide.transform.rotation;
        Vector3 start    = fromPos.position;
        Vector3 toPos    = inter.GetCell().transform.position;
        Vector3 arc      = start + (toPos - start) / 2 + Vector3.up * .5f;
        float   distance = Vector3.Distance(fromPos.position, toPos); //distance - vel=distance/time
        float   time     = distance / dur;

        while (counter < dur)
        {
            counter += Time.deltaTime;
            toPos    = inter.GetCell().transform.position + new Vector3(0, inter.transform.localScale.y / 2, 0);
            Vector3 m1 = Vector3.Lerp(start, arc, counter / dur);
            Vector3 m2 = Vector3.Lerp(arc, toPos, counter / dur);
            fromPos.position = Vector3.Lerp(m1, m2, counter / dur);
            yield return(null);
        }
    }