Example #1
0
    void Update()
    {
        CheckInput();
        UpdateAnim();
        distance += velocity * Time.deltaTime;

        var pos = transform.position;

        float curveOffset = Curvature.Get() * Time.deltaTime * velocity * adhesion;

        pos.x -= curveOffset;

        if (left)
        {
            pos.x = pos.x - (cornerSpeed * Time.deltaTime + Mathf.Abs(curveOffset * 0.4f));
        }

        if (right)
        {
            pos.x = pos.x + (cornerSpeed * Time.deltaTime + Mathf.Abs(curveOffset * 0.4f));
        }

        pos.x = Mathf.Max(pos.x, -max);
        pos.x = Mathf.Min(pos.x, max);

        transform.position = pos;

        Distance.Set(distance);
        Velocity.Set(velocity);
    }
Example #2
0
    public void Update()
    {
        float current = multiplayer;

        for (int i = 0; i < backgrounds.Length; ++i)
        {
            var pos = positions[i];
            pos.x = pos.x + Curvature.Get() * current;
            backgrounds[i].transform.position = pos;
            current *= current;
        }
    }
Example #3
0
 public void Update()
 {
     if (!IsOnScreen())
     {
         Destroy(gameObject);
     }
     else
     {
         offset         += CalculateOffset();
         currentPosition = new Vector2(startPosition.x, startPosition.y + offset);
         perspective     = RoadCommon.PERSPECTIVE(currentPosition.y, RoadSize.Get().y);
         float distanceFromCenter = 0.5f - startPosition.x;
         currentPosition.x += RoadCommon.CURVE(Curvature.Get(), perspective) + distanceFromCenter * perspective;
         ApplyPosition(currentPosition);
     }
 }
Example #4
0
    void Update()
    {
        float distance = Distance.Get();

        material.SetFloat(CurvatureId, Curvature.Get());
        material.SetFloat(DistanceId, distance);

        var newSection = track.FindSection(distance);

        if (newSection != section)
        {
            section = newSection;
            Curvature.Next(section.curvature);
        }

        Curvature.Update(Distance.Delta());
    }