change: altered camera for smoother and more responsive lock-on (mainly jitter from the arbitrary target, locking rotation)

This commit is contained in:
Chris
2025-08-06 15:23:42 -04:00
parent 18a4b5228a
commit 9e8616f8da
13 changed files with 185 additions and 53 deletions

View File

@@ -11,7 +11,7 @@ public struct CameraSettingSingleValue<T>{
public Vector2 velocityRefV2;
public Vector3 velocityRefV3;
public CameraSettingSingleValue(float defaultSmoothing, T original = default(T)){
public CameraSettingSingleValue(float defaultSmoothing = .2f, T original = default(T)){
originalValue = original;
targetValue = original;
smoothing = defaultSmoothing;
@@ -106,11 +106,12 @@ public class CameraSettingsProcessor : MonoBehaviour{
values = new CameraSettingValues{
cameraOffsetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, offset.Offset),
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, main.Lens.FieldOfView),
axisLookEnabledX = new CameraSettingSingleValue<bool>(0f, axisCont.Controllers[0].Enabled),
axisLookEnabledY = new CameraSettingSingleValue<bool>(0f, axisCont.Controllers[1].Enabled),
axisLookEnabledX = new CameraSettingSingleValue<bool>(0, axisCont.Controllers[0].Enabled),
axisLookEnabledY = new CameraSettingSingleValue<bool>(0, axisCont.Controllers[1].Enabled),
axisLookGainX = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, axisCont.Controllers[0].Input.Gain),
axisLookGainY = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, axisCont.Controllers[1].Input.Gain),
orbitPositionDamping = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, orbit.TrackerSettings.PositionDamping),
orbitTargetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .1f, orbit.TargetOffset),
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),

View File

@@ -6,14 +6,44 @@ public interface ILockOnTarget {
Transform transform {get;}
GameObject gameObject{ get; }
abstract void OnTargetDelete();
void Help(){
SafelyDeleteTarget();
}
public Vector3 GetReticlePosition(){
Bounds objectBounds = gameObject.GetComponent<Renderer>().bounds;
float upValue = 0f;
if (gameObject.GetComponent<Renderer>()){
Bounds objectBounds = gameObject.GetComponent<Renderer>().bounds;
upValue = objectBounds.size.y;
}
Vector3 reticlePosition = new Vector3(transform.position.x, transform.position.y + objectBounds.size.y, transform.position.z);
Vector3 reticlePosition = new Vector3(transform.position.x, transform.position.y + upValue, transform.position.z);
return reticlePosition;
}
public void OnEnable(){
Debug.Log("hewwo");
}
public void SafelyDeleteTarget(){
// gameObject.
foreach (LockOnManager.ActiveLockOnTarget target in LockOnManager.Instance.activeTargets) {
if (target.gameObject == this.gameObject) {
GameObject clone = new GameObject{name = $"Target Clone of {gameObject.name}", transform = { position = transform.position}};
Debug.Log("hii");
target.gameObject = clone;
target.cinemachineTarget.Object = clone.transform;
LockOnManager.Instance.QueueTargetRemoval(clone, true);
}
}
}
}
public class PlayerCamera : MonoBehaviour{

View File

@@ -76,7 +76,7 @@ public class PlayerControls : MonoBehaviour{
}
public void OnCancelLockOn(){
GetComponent<LockOnManager>().RemoveLockOnTarget();
GetComponent<LockOnManager>().RemoveMainTarget();
graph.SendEvent<string>("InputEvent", "CancelLockOn", null);
}