public void Shoot(Transform bullet, Vector3 startPos, Vector3 endPos, float g, float max_height, System.Action onComplete)

    {

        start_pos = startPos;

        end_pos = endPos;

        this.g = g;

        this.max_height = max_height;

        this.bullet = bullet;

        this.bullet.position = start_pos;

        var dh = endPos.y - startPos.y;

        var mh = max_height - startPos.y;

        ty = Mathf.Sqrt(2 * this.g * mh);

        float a = this.g;

        float b = -2 * ty;

        float c = 2 * dh;

        dat = (-b + Mathf.Sqrt(b * b - 4 * a * c)) / (2 * a);

        tx = -(startPos.x - endPos.x) / dat;

        tz = -(startPos.z - endPos.z) / dat;

        this.elapsed_time = 0;

        StartCoroutine(this.ShootImpl(onComplete));

    }

    IEnumerator ShootImpl(System.Action onComplete)

    {

        while (true)

        {

            this.elapsed_time += Time.deltaTime;

            var tx = start_pos.x + this.tx * elapsed_time;

            var ty = start_pos.y + this.ty * elapsed_time - 0.5f * g * elapsed_time * elapsed_time;

            var tz = start_pos.z + this.tz * elapsed_time;

            var tpos = new Vector3(tx, ty, tz);

            bullet.transform.LookAt(tpos);

            bullet.transform.position = tpos;

            if (this.elapsed_time >= this.dat)

                break;

            yield return null;

        }

        onComplete();

    }


    private void OnCompleteThrowSimulation()

    {

        Debug.Log("도착");

    }


포물선으로 이동하는 물체 코드인데

왜 계산하는지 모르겠는게 너무 많어.

수학 문제 같은데 누가 좀 알려주라...