Exemplo n.º 1
0
    private IEnumerator MoveCamera()
    {
        Vector3 currentVelocity = Vector3.zero;

        while (activeCameraWaypoints.Count > 0)
        {
            CameraWaypoint cameraWaypoint  = activeCameraWaypoints.ElementAt(activeCameraWaypoints.Count - 1);
            Vector3        desiredPosition = cameraWaypoint.Waypoint.position + offset;

            currentVelocity = Vector3.zero;
            while (Vector3.Distance(cam.transform.position, desiredPosition) > 0.5f)
            {
                cam.transform.position = Vector3.SmoothDamp(cam.transform.position,
                                                            desiredPosition,
                                                            ref currentVelocity,
                                                            cameraWaypoint.CameraMoveSpeed);

                if (cameraWaypoint.UpdateRotation)
                {
                    cam.transform.LookAt(cameraWaypoint.Waypoint.position);
                }

                yield return(new WaitForFixedUpdate());
            }

            activeCameraWaypoints.Remove(cameraWaypoint);
        }

        state.NotifyCameraAnimationDone();
        cam.GetComponent <CameraFollowTarget>().enabled = true;
        coroutine = null;
    }
 public static void PreviousWaypoint()
 {
     waypointNumber--;
     if(waypointNumber < 0)
     {
         waypointNumber = 0;
     }
     gotoLocation = FindCameraWaypoint(waypointNumber);
 }
 public static void NextWaypoint()
 {
     waypointNumber++;
     if(waypointNumber > GetMaximum ())
     {
         waypointNumber = GetMaximum();
     }
     gotoLocation = FindCameraWaypoint (waypointNumber);
 }
Exemplo n.º 4
0
 public void GoToWaypoint(CameraWaypoint waypoint)
 {
     source      = this.transform.position;
     target      = waypoint.transform.position;
     curWaypoint = waypoint;
     if (waypoint.camMode == CameraWaypoint.CamModes.Auto)
     {
         float delta        = (source - target).magnitude;
         float timeToTarget = delta / waypoint.speed;
         Go.to(this.transform, timeToTarget, new GoTweenConfig().position(waypoint.transform.position).onComplete((_) => {
             NextWaypoint();
         }));
     }
 }
Exemplo n.º 5
0
    public void PlaceWaypoint(Vector3 position, Quaternion rotation, float time = -1)
    {
        //animationScript.AddKeyframe(tr);
        GameObject s = CreateWaypointGameObject(position, rotation);

        if (CameraWaypointsDict.Count == 0)
        {
            CreateWaypointContainer(position);

            if (!CloudSelector.instance.noSelection)
            {
                CloudStateInTime state = CreateCloudState();
                InitialState = state;
            }
        }
        s.transform.SetParent(WaypointContainer.transform);

        //Debug.Log("s : " + s.transform.localRotation.eulerAngles);
        //Debug.Log("sphere : " + sphere.transform.rotation.eulerAngles);
        float TimeToAssign;

        if (time >= 0)
        {
            TimeToAssign = time;
        }
        else
        {
            TimeToAssign = WaypointMasterID * KeyFrameTimestep;
        }
        CameraWaypoint campoint = new CameraWaypoint(WaypointMasterID, Mathf.RoundToInt(TimeToAssign));

        campoint.obj = s;
        int indexkey;

        indexkey = animationScript.AddKeyframe(s.transform, campoint.Time);
        WaypointMasterID++;
        campoint.IndexKey = indexkey;

        //Debug.Log("Adding key for point "+campoint.ID+" at time "+campoint.Time+" / Result : "+ campoint.IndexKey);
        //Debug.Log(animationScript.curvePositionX[campoint.IndexKey].ToString());
        CameraWaypointsDict.Add(campoint.ID, campoint);
        //CREATE NEW BUTTON
        UIMenu.CreateTimeButton(campoint.ID, campoint.Time);
        CalculateAnimationDuration();
        ReloadMesh();
    }