예제 #1
0
    void LateUpdate()
    {
        if (!recording || GameObject.Find("Player").GetComponent <Renderer>().enabled == false)
        {
            lineRenderer.enabled = false;
        }
        else
        {
            lineRenderer.enabled = true;
        }

        // Automatically dequeue old points
        int pointsToKeep = (int)(maxLineTime * fps);

        while (linePoints.Count > pointsToKeep)
        {
            linePoints.Dequeue();
        }

        // Add all vertices to line renderer
        int i = 0;

        lineRenderer.SetColors(Color.clear, lineColour);
        lineRenderer.SetVertexCount(linePoints.Count + 1);
        foreach (Vector3 point in linePoints)
        {
            lineRenderer.SetPosition(i, point);
            i++;
        }

        if (enableLine && linePoints.Count > 0)
        {
            lineRenderer.SetPosition(i, transform.position + offset);
        }

        if (playback && current != null)
        {
            if (!TutorialCamera.Enabled())
            {
                GUIController.GUIPlaybackRecording();

                ControlManager.Disabled = true;

                GUIController.ShowText("Replay", "Replay Mode");
            }

            time += Time.deltaTime;

            if (time < current.score.time)
            {
                transform.position = current.GetPosition(time);
                if (!GetComponent <Rigidbody>().isKinematic)
                {
                    GetComponent <Rigidbody>().velocity = current.GetVelocity(time);
                }

                transform.LookAt(transform.position + GetComponent <Rigidbody>().velocity);

                if (current.IsGrappling(time) && current.GetGrapplePos(lastTime) != current.GetGrapplePos(time))
                {
                    if (!current.IsGrappling(lastTime))
                    {
                        SoundManager.Play("attach");
                    }

                    RaycastHit hit = new RaycastHit();
                    hit.point = current.GetGrapplePos(time);

                    grappleScript.Attach(hit, -1, true);
                }
                else if (!current.IsGrappling(time) && current.IsGrappling(lastTime))
                {
                    grappleScript.Detach();
                }
            }

            lastTime = time;
        }
    }