예제 #1
0
    // Update is called once per frame
    void Update()
    {
        float dist = Vector3.Distance (wayPoint.transform.position, transform.position);
        if (dist < 0.5f) {
            // we have arrived (close enough)
            delayTime += Time.deltaTime;
            if (delayTime >= wayPoint.delay) {
                delayTime = 0;
                if (wayPoint.nextWayPoint != null) {
                    wayPoint = wayPoint.nextWayPoint;
                } else {
                    // no more waypoints. lets go to main game camera.
                    wayPoint.narrativeText ="";
                    this.gameObject.SetActive(false);
                    endCamera.gameObject.SetActive (true);
                }
            }
        }

        if (wayPoint != null && wayPoint.narrativeText != null) {
            narrativeText.text = wayPoint.narrativeText;
        }

        transform.position =  Vector3.SmoothDamp(transform.position, wayPoint.transform.position, ref velocity, 0.1f);
        transform.LookAt(wayPoint.lookAtTarget.transform.position);
    }
예제 #2
0
    // calculate which transform's we're interpolating between
    private void CalculateFromAndToTransformAndTime(ref PosAndQuat fromTransform, ref float fromTime,
                                                    ref PosAndQuat toTransform, ref float toTime)
    {
        CameraWayPoint fromWayPoint = null;
        CameraWayPoint toWayPoint   = null;

        CalculateFromAndToWayPointTransformAndTime(ref fromWayPoint, ref fromTransform, ref fromTime, ref toWayPoint, ref toTransform, ref toTime);
    }
예제 #3
0
    // calculate which way points we're interpolating between
    private void CalculateFromAndToWayPoint(ref CameraWayPoint fromWayPoint, ref CameraWayPoint toWayPoint)
    {
        PosAndQuat fromTransform = new PosAndQuat();
        float      fromTime      = 0f;

        PosAndQuat toTransform = new PosAndQuat();
        float      toTime      = 0f;

        CalculateFromAndToWayPointTransformAndTime(ref fromWayPoint, ref fromTransform, ref fromTime, ref toWayPoint, ref toTransform, ref toTime);
    }
예제 #4
0
 static public bool IsWayPointHoldActive(CameraWayPoint point)
 {
     if (null != _activeCinematic && null != point)
     {
         CameraWayPoint fromWayPoint = null;
         CameraWayPoint toWayPoint   = null;
         _activeCinematic.CalculateFromAndToWayPoint(ref fromWayPoint, ref toWayPoint);
         return(point == toWayPoint && point == fromWayPoint);
     }
     return(false);
 }
예제 #5
0
 static public bool IsWayPointLerpOutActive(CameraWayPoint point)
 {
     if (null != _activeCinematic && null != point)
     {
         CameraWayPoint fromWayPoint = null;
         CameraWayPoint toWayPoint   = null;
         _activeCinematic.CalculateFromAndToWayPoint(ref fromWayPoint, ref toWayPoint);
         // only the last way point can have an active lerp out, all other way points, the following way point lerp in will override
         return(point == fromWayPoint && (point == _activeCinematic.cameraWayPoints[_activeCinematic.cameraWayPoints.Count - 1]) && point != toWayPoint && null == toWayPoint);
     }
     return(false);
 }
예제 #6
0
    // calculate which transform's we're interpolating between
    private void CalculateFromAndToWayPointTransformAndTime(ref CameraWayPoint fromWayPoint, ref PosAndQuat fromTransform, ref float fromTime,
                                                            ref CameraWayPoint toWayPoint, ref PosAndQuat toTransform, ref float toTime)
    {
        float currentCinematicTime = GetCinematicCurrentTime();

        _cameraComponent.GetGameCameraTransform(ref fromTransform.position, ref fromTransform.rotation);
        toTransform = fromTransform;

        fromWayPoint = null;
        toWayPoint   = fromWayPoint;

        fromTime = 0f;
        for (int wayPoint = 0; wayPoint < cameraWayPoints.Count; ++wayPoint)
        {
            CameraWayPoint currentWayPoint = cameraWayPoints[wayPoint];

            fromTime += currentWayPoint.lerpInTime;
            if (currentCinematicTime < fromTime)
            {
                toTime      = fromTime;
                toTransform = currentWayPoint.CalculateTransform(_cameraComponent);
                toWayPoint  = currentWayPoint;

                fromTime -= currentWayPoint.lerpInTime;
                return;
            }
            fromTransform = currentWayPoint.CalculateTransform(_cameraComponent);
            fromWayPoint  = currentWayPoint;

            fromTime += currentWayPoint.holdTime;
            if (currentCinematicTime < fromTime)
            {
                toTime      = fromTime;
                toTransform = fromTransform;
                toWayPoint  = fromWayPoint;

                fromTime -= currentWayPoint.holdTime;
                return;
            }

            if (cameraWayPoints.Count - 1 == wayPoint)             // the last way point
            {
                toTime = fromTime + currentWayPoint.lerpOutTime;   // out length is only used on the last way point
            }
        }
    }