changed: fov and better offset. parallelized grapple change.
This commit is contained in:
@@ -9,14 +9,16 @@ public struct CameraSettingSingleValue<T>{
|
||||
|
||||
public float velocityRef;
|
||||
public Vector2 velocityRefV2;
|
||||
public Vector3 velocityRefV3;
|
||||
|
||||
public CameraSettingSingleValue(float defaultSmoothing, T original = default(T)){
|
||||
originalValue = original;
|
||||
targetValue = default(T);
|
||||
targetValue = original;
|
||||
smoothing = defaultSmoothing;
|
||||
|
||||
velocityRef = 0;
|
||||
velocityRefV2 = default;
|
||||
velocityRefV3 = default;
|
||||
}
|
||||
|
||||
public void Reset(){
|
||||
@@ -25,6 +27,8 @@ public struct CameraSettingSingleValue<T>{
|
||||
}
|
||||
|
||||
public struct CameraSettingValues{
|
||||
public CameraSettingSingleValue<float> mainFieldOfView;
|
||||
|
||||
public CameraSettingSingleValue<float> orbitFollowTopHeight;
|
||||
public CameraSettingSingleValue<float> orbitFollowTopRadius;
|
||||
public CameraSettingSingleValue<float> orbitFollowCenterHeight;
|
||||
@@ -33,8 +37,12 @@ public struct CameraSettingValues{
|
||||
public CameraSettingSingleValue<float> orbitFollowBottomRadius;
|
||||
|
||||
public CameraSettingSingleValue<Vector2> rotationComposerScreenPos;
|
||||
|
||||
public CameraSettingSingleValue<Vector3> cameraOffsetOffset;
|
||||
|
||||
public CameraSettingValues(float defaultSmoothing){
|
||||
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
|
||||
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowCenterHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
@@ -43,6 +51,7 @@ public struct CameraSettingValues{
|
||||
orbitFollowBottomRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
|
||||
rotationComposerScreenPos = new CameraSettingSingleValue<Vector2>(defaultSmoothing);
|
||||
cameraOffsetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,46 +62,45 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
|
||||
public static GameObject mainCamera;
|
||||
|
||||
private CinemachineCamera main;
|
||||
private CinemachineOrbitalFollow orbit;
|
||||
private CinemachineRotationComposer rotComp;
|
||||
private CinemachineCameraOffset offset;
|
||||
|
||||
public void Awake(){
|
||||
// Singleton management
|
||||
if (Instance != null && Instance != this) {
|
||||
Destroy(this);
|
||||
} else {
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
// Set references for camera object and cinemachine components
|
||||
mainCamera = gameObject;
|
||||
main = mainCamera.GetComponent<CinemachineCamera>();
|
||||
orbit = mainCamera.GetComponent<CinemachineOrbitalFollow>();
|
||||
rotComp = mainCamera.GetComponent<CinemachineRotationComposer>();
|
||||
offset = mainCamera.GetComponent<CinemachineCameraOffset>();
|
||||
|
||||
StashCameraOriginalSettings(this);
|
||||
SetTargetsToOriginalValues(this);
|
||||
// Initialize camera settings values
|
||||
values = new CameraSettingValues{
|
||||
cameraOffsetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, offset.Offset),
|
||||
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, main.Lens.FieldOfView),
|
||||
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Height),
|
||||
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Radius),
|
||||
orbitFollowCenterHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Center.Height),
|
||||
orbitFollowCenterRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Center.Radius),
|
||||
orbitFollowBottomHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Bottom.Height),
|
||||
orbitFollowBottomRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Bottom.Radius),
|
||||
rotationComposerScreenPos = new CameraSettingSingleValue<Vector2>(defaultSmoothing: .2f, rotComp.Composition.ScreenPosition),
|
||||
};
|
||||
}
|
||||
|
||||
public static void StashCameraOriginalSettings(CameraSettingsProcessor settings){
|
||||
values.orbitFollowTopHeight.originalValue = settings.orbit.Orbits.Top.Height;
|
||||
values.orbitFollowTopRadius.originalValue = settings.orbit.Orbits.Top.Radius;
|
||||
values.orbitFollowCenterHeight.originalValue = settings.orbit.Orbits.Center.Height;
|
||||
values.orbitFollowCenterRadius.originalValue = settings.orbit.Orbits.Center.Radius;
|
||||
values.orbitFollowBottomHeight.originalValue = settings.orbit.Orbits.Bottom.Height;
|
||||
values.orbitFollowBottomRadius.originalValue = settings.orbit.Orbits.Bottom.Radius;
|
||||
|
||||
values.rotationComposerScreenPos.originalValue = settings.rotComp.Composition.ScreenPosition;
|
||||
}
|
||||
|
||||
public static void SetTargetsToOriginalValues(CameraSettingsProcessor settings){
|
||||
values.orbitFollowTopHeight.Reset();
|
||||
values.orbitFollowTopRadius.Reset();
|
||||
values.orbitFollowCenterHeight.Reset();
|
||||
values.orbitFollowCenterRadius.Reset();
|
||||
values.orbitFollowBottomHeight.Reset();
|
||||
values.orbitFollowBottomRadius.Reset();
|
||||
values.rotationComposerScreenPos.Reset();
|
||||
}
|
||||
|
||||
|
||||
void ProcessCameraValues(){
|
||||
main.Lens.FieldOfView = Mathf.SmoothDamp(main.Lens.FieldOfView,
|
||||
values.mainFieldOfView.targetValue, ref values.mainFieldOfView.velocityRef,
|
||||
values.mainFieldOfView.smoothing);
|
||||
|
||||
orbit.Orbits.Top.Height = Mathf.SmoothDamp(orbit.Orbits.Top.Height,
|
||||
values.orbitFollowTopHeight.targetValue, ref values.orbitFollowTopHeight.velocityRef,
|
||||
values.orbitFollowTopHeight.smoothing);
|
||||
@@ -120,6 +128,10 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
rotComp.Composition.ScreenPosition = Vector2.SmoothDamp(rotComp.Composition.ScreenPosition,
|
||||
values.rotationComposerScreenPos.targetValue, ref values.rotationComposerScreenPos.velocityRefV2,
|
||||
values.rotationComposerScreenPos.smoothing);
|
||||
|
||||
offset.Offset = Vector3.SmoothDamp(offset.Offset,
|
||||
values.cameraOffsetOffset.targetValue, ref values.cameraOffsetOffset.velocityRefV3,
|
||||
values.cameraOffsetOffset.smoothing);
|
||||
}
|
||||
|
||||
void Update(){
|
||||
|
||||
Reference in New Issue
Block a user