예제 #1
0
        private void FixedUpdate()
        {
            if (!alignToPath)
            {
                return;
            }

            var p = transform.position + transform.forward * (speedMs * Time.fixedDeltaTime);

            if (positionByClosestPoint)
            {
                var pathP = pathAdapter.GetClosestPointOnPath(p, out var closestDistance);
                transform.position = pathP;
                transform.rotation = pathAdapter.GetRotationAtDistance(closestDistance);
            }
            else
            {
                var closestDistance = pathAdapter.GetClosestDistanceAlongPath(p);
                var pathP           = pathAdapter.GetPointAtDistance(closestDistance);
                transform.position = pathP;
                transform.rotation = pathAdapter.GetRotationAtDistance(closestDistance);
            }
        }
예제 #2
0
        private void FixedUpdate()
        {
            var position = pathAdapter.GetPointAtDistance(cameraPosition);
            var lookAt   = pathAdapter.GetRotationAtDistance(cameraPosition);

            cameraToFollow.transform.position = position + Vector3.up * 5f;
            cameraToFollow.transform.rotation = lookAt;

            cameraPosition += Time.deltaTime * speedMs;
            if (cameraPosition > pathAdapter.TotalDistance)
            {
                cameraPosition = 0f;
            }
        }