예제 #1
0
파일: Navigator.cs 프로젝트: sebjf/Pod-like
    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
파일: PathCache.cs 프로젝트: sebjf/Pod-like
    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);
        }
    }