コード例 #1
0
        public void HandleCameraView()
        {
            if (pluginSettings.ready)
            {
                // Call the camera's behavior.
                currentCamera.ApplyBehavior(ref cameraPositionTarget, ref cameraLookAtTarget, player, isCameraStatic);
                isCameraStatic = currentCamera.staticCamera;


                if (currentAvatar != null)
                {
                    if (pluginSettings.removeAvatarInsteadOfHead)
                    {
                        currentAvatar.avatarSettings.showAvatar.Value = !currentCamera.removeHead;
                    }
                    else
                    {
                        currentAvatar.avatarSettings.showAvatarHead.Value = !currentCamera.removeHead;
                    }
                    timerHelper.ResetRemoveAvatarTimer();
                }

                cameraPosition = Vector3.SmoothDamp(cameraPosition, cameraPositionTarget, ref cameraVelocity, currentCamera.GetBetweenTime());
                cameraLookAt   = Vector3.SmoothDamp(cameraLookAt, cameraLookAtTarget, ref cameraLookAtVelocity, currentCamera.GetBetweenTime());

                Vector3 lookDirection = cameraLookAt - cameraPosition;

                Quaternion rotation = currentCamera.GetRotation(lookDirection, player);

                cameraHelper.UpdateCameraPose(cameraPosition, rotation, currentCamera.GetFOV());
            }
        }
コード例 #2
0
    public void OnLateUpdate()
    {
        if (target == null)
        {
            pathNameDisplay.text = "Error: Camera target missing!";
            return;
        }
        Vector3 newPos = spline.PointAtTime(Time.time * speed, c);

        helper.UpdateCameraPose(newPos, Quaternion.LookRotation(target.position - newPos, Vector3.up));
    }
コード例 #3
0
        public Vector3 menuCamUpdate(PluginCameraHelper helper)
        {
            Vector3 pos = Vector3.SmoothDamp(WorldCam.position, camPos, ref camPosVel, .5f);

            camLookPos = Vector3.SmoothDamp(camLookPos, camLook, ref camLookVel, .5f);
            Quaternion rot = Quaternion.LookRotation(camLookPos - WorldCam.position);

            helper.UpdateCameraPose(pos, rot);

            return(camLookPos);
        }
    // OnUpdate is called once every frame and it is used for moving with the camera so it can be smooth as the framerate.
    // When you are reading other transform positions during OnUpdate it could be possible that the position comes from a previus frame
    // and has not been updated yet. If that is a concern, it is recommended to use OnLateUpdate instead.
    public void OnUpdate()
    {
        _elaspedTime += Time.deltaTime * _settings.speed;
        Transform headTransform = _helper.playerHead;

        ProcessFOVEMultipler();

        Vector3    rotationVector       = headTransform.forward * _settings.distance;
        Vector3    targetCameraPosition = headTransform.position - rotationVector;
        Quaternion targetCameraRotation = Quaternion.LookRotation(headTransform.forward);

        _helper.UpdateCameraPose(targetCameraPosition, targetCameraRotation);
        _helper.UpdateFov(_settings.fov);
    }
コード例 #5
0
        //private Vector3 CameraPosition; //LocalPosition of the camera in relation to the rigCamObject.
        public Vector3 PositionUpdate(PluginCameraHelper camhelper)
        {
            waiting -= Time.deltaTime;
            if (waiting < 0.0f)
            {
                waiting += UnityEngine.Random.Range(timeMin, timeMax);

                CameraTargetPosition = CameraLooks[UnityEngine.Random.Range(0, CameraLooks.Count)];
            }
            CameraLook.transform.position = Vector3.SmoothDamp(CameraLook.transform.position, CameraTargetPosition, ref CameraTargetPositionVelocity, responsiveness);



            //get floor position of the head.
            Vector3 headFloorPoint = new Vector3(camhelper.playerHead.position.x, 0.0f, camhelper.playerHead.position.z);
            Vector3 aheaddistance  = new Vector3(0.0f, 0.0f, 1.0f);
            Vector3 ahead          = camhelper.playerHead.TransformPoint(aheaddistance);

            ahead = new Vector3(ahead.x, 0.0f, ahead.z);//Directional vector from headfloorpoint.

            FloorReference.transform.position = headFloorPoint;
            FloorReference.transform.rotation = Quaternion.LookRotation(ahead - headFloorPoint);

            //update the look point.

            RigCamObject.transform.position = Vector3.SmoothDamp(RigCamObject.transform.position, FloorReference.transform.TransformPoint(RigCamObjectPositionGoal), ref RigCamObjectVelocity, responsiveness);
            RigCamObject.transform.rotation = Quaternion.LookRotation(CameraLook.transform.position - RigCamObject.transform.position);

            //orlCam.position = UpdateCameraWithThis.transform.position;
            //worlCam.rotation = UpdateCameraWithThis.transform.rotation;
            camhelper.UpdateCameraPose(UpdateCameraWithThis.transform.position, UpdateCameraWithThis.transform.rotation);



            return(CameraLook.transform.position);
        }