void Update()
    {
        float   t        = (Time.time - t0) / rocketFlightTime;
        Vector3 position = bezier.GetPoint(t);
        Vector3 velocity = bezier.GetVelocity(t);

        transform.position = position;
        if (velocity.sqrMagnitude > 0f)
        {
            transform.rotation = Quaternion.LookRotation(velocity);
        }

        if (fizzleOutTimes == null)
        {
            if (t >= 1f)
            {
                BattleController.instance.Strike(atWhose, targetPosition);
                FizzleOut(Mathf.Max(.3f, .3f * rocketFlightTime));
                if (callback != null)
                {
                    callback();
                }
            }
        }

        if (fizzleOutTimes != null)
        {
            source.volume = (fizzleOutTimes [1] - Time.time) / (fizzleOutTimes [1] - fizzleOutTimes [0]);
        }
    }
Beispiel #2
0
    private void OnSceneGUI()
    {
        BezierController bezier = target as BezierController;

        Handles.color = Color.white;
        Handles.DrawDottedLine(bezier.t0.position, bezier.t3.position, 5f);
        DoPositionHandle(bezier.t0);
        DoPositionHandle(bezier.t1);
        DoPositionHandle(bezier.t2);
        DoPositionHandle(bezier.t3);
        Handles.DrawBezier(bezier.t0.position, bezier.t3.position, bezier.t1.position, bezier.t2.position, Color.white, null, 4f);
        GUIStyle style = new GUIStyle();

        style.fontSize = 20;
        Handles.Label(bezier.t0.position, "T0", style);
        Handles.Label(bezier.t1.position, "T1", style);
        Handles.Label(bezier.t2.position, "T2", style);
        Handles.Label(bezier.t3.position, "T3", style);
        for (int i = 0; i < STEPS; i++)
        {
            float t = (float)i / STEPS;
            Handles.color = Color.green;
            Vector3 point    = bezier.GetPoint(t);
            Vector3 velocity = bezier.GetVelocity(t);
            Handles.DrawLine(point, point + velocity.normalized * 2f);
        }
    }