Exemplo n.º 1
0
    /// <summary>
    /// Updates the car position by asking the RoadSegment path.
    /// </summary>
    void UpdatePosition()
    {
        pDist += Time.deltaTime * speed; //Update the path distance traversed
        if (pDist < currentConnection.path.length)
        {
            transform.position = currentConnection.path.GetPosition(pDist, 0); //Ask the current road segment for position
            return;
        }

        //If we have traversed more distance than the current path, it means we are in a new RoadSegment
        previousRoadSegment = currentRoadSegment;
        currentRoadSegment  = currentConnection.exitBorder.rs;
        currentConnection   = currentRoadSegment.GetConnection(this);
        pDist = 0; //reset path distance
    }
Exemplo n.º 2
0
    public Sprite[] carSprites; //Sprites for visualizing changes in direction

    private void Start()
    {
        spriteRenderer = GetComponent <SpriteRenderer>();
        currentRoadSegment.GetConnection(this);
    }