Ejemplo n.º 1
0
    /// <summary>
    /// Show and translates the passed object to match the direction and length of the flicking vector.
    /// </summary>
    /// <param name="lineObject"></param>
    void DrawUILinePull(GameObject lineObject)
    {
        // Show the line
        SetUILineVisibility(lineObject, true);

        // Get the translation vectors
        Vector3   additionalOffset = new Vector3(0f, 0.3f, 0f);
        Transform flickingObject   = _stateMachine.GetFlickingObjectTransform();
        // This is the center of the flicking object regardless of its rotation.
        Vector3 from = flickingObject.position + (flickingObject.rotation * additionalOffset);
        Vector3 to   = from + new Vector3(flickDirection.x, 0f, flickDirection.z);

        // Center the position of the line object
        lineObject.transform.position = from;

        // Rotate the object
        lineObject.transform.LookAt(to);

        // Scale the line object
        Vector3 lineLength = new Vector3(1f, 1f, (flickMagnitude * 0.5f));

        lineObject.transform.localScale = lineLength;
    }