Пример #1
0
    protected virtual void OnDrawGizmosSelected()
    {
        if (!Application.isPlaying)
        {
            FixedUpdate();
        }

        if (waypoints == null)
        {
            waypoints = GetComponentInParent <TrackGeometry>();
        }

        if (waypoints == null)
        {
            return;
        }

        var query = waypoints.Query(Distance);

        var midline = query.Midpoint;
        var forward = query.Forward;

        Gizmos.color = Color.green;
        Gizmos.DrawLine(midline, position);
        Gizmos.color = Color.red;
        Gizmos.DrawRay(midline, forward);
    }
Пример #2
0
    public static void PlacePrefab(Transform car, TrackPath geometry, float distance, float offset)
    {
        var q = geometry.Query(distance);

        car.position = q.Midpoint + (q.Tangent * offset) + car.localPosition;
        car.forward  = q.Forward;
        car.up       = q.Up;
    }
Пример #3
0
    public PathCache(TrackPath path, float resolution)
    {
        this.path       = path;
        this.resolution = resolution;

        table = new PathQuery[Mathf.CeilToInt(path.totalLength / resolution)];
        for (float d = 0; d < path.totalLength; d += resolution)
        {
            table[Lower(d)] = path.Query(d);
        }
    }