Exemplo n.º 1
0
    } //centerLine of PlayerCar in PCH

    public void DrawCenterLine(GameObject car, float carTf, CurvySpline curvySpline, Texture2D lineRendererTxt)
    {
        Vector3 heading        = curvySpline.Interpolate(0) - car.transform.position;
        float   increaseAmount = 1f / (curvySpline.Length * SPLINE_GIZMO_SMOOTHNESS);

        if (Vector3.Dot(heading, car.transform.forward) > 0) //starting point is in front of me
        {
            for (float i = carTf; i > 0; i -= increaseAmount)
            {
                Vector3 pos = curvySpline.Interpolate(i);
                CenterPoints.Add(pos);
            }
        }
        else //starting point is behind me
        {
            for (float i = carTf; i < 1; i += increaseAmount)
            {
                Vector3 pos = curvySpline.Interpolate(i);
                CenterPoints.Add(pos);
            }
        }

        lineRenderer2.positionCount = CenterPoints.Count;
        lineRenderer2.SetPositions(CenterPoints.ToArray());
        lineRenderer2.colorGradient = MakeLineRendererGradient(centerLineColor);
        lineRenderer2.material.SetColor("_Color", CenterLineColor); //set tint color of lineRenderer
        Texture2D txt = UpdateParams(centerLineColor, lineRendererTxt);

        lineRenderer2.material.SetTexture("_MainTex", txt);
        CenterPoints.Clear();
    } //centerLine of PlayerCar in SF
Exemplo n.º 2
0
 public void ResetMoveData()
 {
     Rect.anchoredPosition = TargetPos;
     IsBehindCenterPoint   = false;
     CenterPoints.Clear();
     CircleXMax.Clear();
     CircleXMin.Clear();
 }
Exemplo n.º 3
0
    } //NavigationLine of PlayerCar and TrafficCar in SF

    public void DrawCenterLine(float carTf, PlayerCarLines.Lane lane, CurvySpline curvySpline, Texture2D lineRendererTxt)
    {
        float increaseAmount = 1f / (curvySpline.Length * SPLINE_GIZMO_SMOOTHNESS);

        float endTf = carTf;

        if (lane.Equals(PlayerCarLines.Lane.RIGHT))
        {
            int direction = 1;
            curvySpline.MoveByLengthFast(ref endTf, ref direction, 75.0f, CurvyClamping.Clamp); //this is to determine a constant length of the curve drawn, since Tf isn't proportional to the curve length, so you can't use a constant value!
            for (float i = carTf; i < endTf; i += increaseAmount)
            {
                Vector3 pos = curvySpline.Interpolate(i);
                CenterPoints.Add(pos);
            }
        }
        else
        {
            int direction = -1;
            curvySpline.MoveByLengthFast(ref endTf, ref direction, 75.0f, CurvyClamping.Clamp); //this is to determine a constant length of the curve drawn, since Tf isn't proportional to the curve length, so you can't use a constant value!
            for (float i = carTf; i > endTf; i -= increaseAmount)
            {
                Vector3 pos = curvySpline.Interpolate(i);
                CenterPoints.Add(pos);
            }
        }

        lineRenderer2.positionCount = CenterPoints.Count;
        lineRenderer2.SetPositions(CenterPoints.ToArray());
        lineRenderer2.colorGradient = MakeLineRendererGradient(centerLineColor);
        lineRenderer2.material.SetColor("_Color", CenterLineColor); //set tint color of particle shader
        Texture2D txt = UpdateParams(centerLineColor, lineRendererTxt);

        lineRenderer2.material.SetTexture("_MainTex", txt);
        CenterPoints.Clear();
    } //centerLine of PlayerCar in PCH