// Update is called once per frame
    void Update()
    {
        if (pc.playing)
        {
            GetComponent <Animation>().Play();
        }
        else
        {
            GetComponent <Animation>().Stop();
        }

        int index = _getTrait(positions, pc.current_time);

        if (index < positions.Count - 1 && index > -1)
        {
            r.enabled = true;
            PedestrianPosition pos  = (PedestrianPosition)positions.GetByIndex(index);
            PedestrianPosition pos2 = (PedestrianPosition)positions.GetByIndex(index + 1);
            start  = new Vector3(pos.getX(), 0, pos.getY());
            target = new Vector3(pos2.getX(), 0, pos2.getY());
            float   time = (float)pc.current_time;
            float   movement_percentage = (float)time - (float)pos.getTime();
            Vector3 newPosition         = Vector3.Lerp(start, target, movement_percentage);

            Vector3 relativePos = target - start;
            speed = relativePos.magnitude;

            GetComponent <Animation>()["walking"].speed = getSpeed();
            if (start != target)
            {
                transform.rotation = Quaternion.LookRotation(relativePos);
            }

            if (gp.point1active && gp.point2active)
            {
                if (FasterLineSegmentIntersection(new Vector2(gp.point1.x, gp.point1.z), new Vector2(gp.point2.x, gp.point2.z), new Vector2(transform.position.x, transform.position.z), new Vector2(newPosition.x, newPosition.z)))
                {
                    gp.lineCross(speed);
                }
            }

            if (pc.tileColoringMode != TileColoringMode.TileColoringNone)
            {
                tile.GetComponent <Renderer>().enabled = true;

                if (pc.tileColoringMode == TileColoringMode.TileColoringSpeed)
                {
                    tile.GetComponent <Renderer>().material.color = ColorHelper.ColorForSpeed(getSpeed());
                    it.updateSpeed(speed);
                }
                else if (pc.tileColoringMode == TileColoringMode.TileColoringDensity)
                {
                    densityReload = (densityReload + 1) % densityReloadInterval;
                    if (densityReload == 0)
                    {
                        getDensity();
                    }
                    float density = getDensity();
                    tile.GetComponent <Renderer>().material.color = ColorHelper.ColorForDensity(density);
                }
            }
            else
            {
                tile.GetComponent <Renderer>().enabled = false;
            }

            transform.position   = newPosition;
            gameObject.hideFlags = HideFlags.None;
        }
        else
        {
            r.enabled = false;
            tile.GetComponent <Renderer>().enabled = false;
            gameObject.hideFlags = HideFlags.HideInHierarchy;
        }
    }