Bezier.GetDirection C# (CSharp) Méthode

GetDirection() public méthode

public GetDirection ( float t ) : Vector3
t float
Résultat Vector3
    public Vector3 GetDirection(float t)
    {
        return DerivOnBezier(p0,p1,p2,p3,t).normalized;
    }

Usage Example

Exemple #1
0
    private bool m_ended = false;               //Bool that turns true if disc reaches end of Bezier curve and hasn't collided with anything.


    // Update is called once per frame
    void Update()
    {
        //Get flight duration from DiscController and DiscThrow sripts.
        m_duration = (GetComponentInParent <DiscController>().m_durationmulti *DiscThrow.m_styledurationmulti);

        //If disc hasn't collided...
        if (!m_Collided)
        {
            //...move disc along the curve
            Vector3 tepm = m_curve.GetVelocity(0.98f).normalized *m_duration;
            m_progress += Time.deltaTime / (m_duration * m_timemulti);
            Vector3 position = m_curve.GetPoint(m_progress);

            //If disc has nearly reached end of Bezier curve change m_ended to true and set velocity of disc.
            if (m_progress >= 0.99f && !m_ended)
            {
                m_ended         = true;
                m_rigb.velocity = tepm;
                print("m_rigb: " + m_rigb.velocity);
            }
            //Move disc with rigidbody and velocity to last known position on the Bezier path and let physics take over.
            else if (m_progress <= 1f)
            {
                transform.position = position;
                print("m_rigb normal: " + m_rigb);
            }
            //If bool look forward is true, transform disc along with the direction of curve.
            if (m_lookForward)
            {
                transform.LookAt(position + m_curve.GetDirection(m_progress));
            }
        }
    }
All Usage Examples Of Bezier::GetDirection