Mini demo with all features
This commit is contained in:
@@ -56,25 +56,6 @@ public class ArmEquipment
|
||||
[Tooltip("Curve for transition movement")]
|
||||
public AnimationCurve TransitionCurve = AnimationCurve.EaseInOut(0, 0, 1, 1);
|
||||
|
||||
[Header("Tap Animation")]
|
||||
[Tooltip("Elbow rotation during windup (degrees)")]
|
||||
public float TapWindupRotation = 15f;
|
||||
|
||||
[Tooltip("Duration of windup (pull back)")]
|
||||
public float TapWindupDuration = 0.1f;
|
||||
|
||||
[Tooltip("Duration of strike (forward snap)")]
|
||||
public float TapStrikeDuration = 0.05f;
|
||||
|
||||
[Tooltip("Wrist snap rotation during strike (degrees)")]
|
||||
public float TapWristSnapRotation = 10f;
|
||||
|
||||
[Tooltip("Shake intensity during vibration")]
|
||||
public float ShakeIntensity = 2f;
|
||||
|
||||
[Tooltip("Shake speed (frequency)")]
|
||||
public float ShakeSpeed = 30f;
|
||||
|
||||
[HideInInspector] public ArmState State = ArmState.Environmental;
|
||||
[HideInInspector] public Vector3 OriginalTargetPosition;
|
||||
[HideInInspector] public Quaternion OriginalTargetRotation;
|
||||
@@ -92,6 +73,7 @@ public class ArmEquipment
|
||||
|
||||
private int _tapTweenId = -1;
|
||||
private bool _isShaking = false;
|
||||
private TapAnimationSettings _currentShakeSettings;
|
||||
|
||||
private Quaternion _transitionStartShoulder;
|
||||
private Quaternion _transitionStartElbow;
|
||||
@@ -376,9 +358,9 @@ public class ArmEquipment
|
||||
_isShaking = false;
|
||||
}
|
||||
|
||||
public void PlayTapAnimation()
|
||||
public void PlayTapAnimation(TapAnimationSettings settings)
|
||||
{
|
||||
if (State != ArmState.Equipped)
|
||||
if (State != ArmState.Equipped || settings == null)
|
||||
return;
|
||||
|
||||
if (_tapTweenId != -1)
|
||||
@@ -389,13 +371,13 @@ public class ArmEquipment
|
||||
Quaternion elbowStart = ElbowBone != null ? ElbowBone.localRotation : Quaternion.identity;
|
||||
Quaternion wristStart = WristBone != null ? WristBone.localRotation : Quaternion.identity;
|
||||
|
||||
Quaternion elbowWindup = elbowStart * Quaternion.Euler(0, 0, -TapWindupRotation);
|
||||
Quaternion elbowStrike = elbowStart * Quaternion.Euler(0, 0, TapWindupRotation * 0.3f);
|
||||
Quaternion elbowWindup = elbowStart * Quaternion.Euler(0, 0, -settings.WindupRotation);
|
||||
Quaternion elbowStrike = elbowStart * Quaternion.Euler(0, 0, settings.WindupRotation * 0.3f);
|
||||
|
||||
Quaternion wristWindup = wristStart;
|
||||
Quaternion wristStrike = wristStart * Quaternion.Euler(0, 0, -TapWristSnapRotation);
|
||||
Quaternion wristStrike = wristStart * Quaternion.Euler(0, 0, -settings.WristSnapRotation);
|
||||
|
||||
_tapTweenId = LeanTween.value(IkLimb.gameObject, 0f, 1f, TapWindupDuration)
|
||||
_tapTweenId = LeanTween.value(IkLimb.gameObject, 0f, 1f, settings.WindupDuration)
|
||||
.setOnUpdate((float t) => {
|
||||
if (ElbowBone != null)
|
||||
{
|
||||
@@ -407,7 +389,7 @@ public class ArmEquipment
|
||||
}
|
||||
})
|
||||
.setOnComplete(() => {
|
||||
_tapTweenId = LeanTween.value(IkLimb.gameObject, 0f, 1f, TapStrikeDuration)
|
||||
_tapTweenId = LeanTween.value(IkLimb.gameObject, 0f, 1f, settings.StrikeDuration)
|
||||
.setOnUpdate((float t) => {
|
||||
if (ElbowBone != null)
|
||||
{
|
||||
@@ -437,22 +419,24 @@ public class ArmEquipment
|
||||
}).id;
|
||||
}
|
||||
|
||||
public void StartShake()
|
||||
public void StartShake(TapAnimationSettings settings)
|
||||
{
|
||||
_isShaking = true;
|
||||
_currentShakeSettings = settings;
|
||||
}
|
||||
|
||||
public void StopShake()
|
||||
{
|
||||
_isShaking = false;
|
||||
_currentShakeSettings = null;
|
||||
}
|
||||
|
||||
public void UpdateShake()
|
||||
{
|
||||
if (!_isShaking || State != ArmState.Equipped || WristBone == null)
|
||||
if (!_isShaking || State != ArmState.Equipped || WristBone == null || _currentShakeSettings == null)
|
||||
return;
|
||||
|
||||
float shake = Mathf.Sin(UnityEngine.Time.time * ShakeSpeed) * ShakeIntensity;
|
||||
float shake = Mathf.Sin(UnityEngine.Time.time * _currentShakeSettings.ShakeSpeed) * _currentShakeSettings.ShakeIntensity;
|
||||
Quaternion shakeRotation = Quaternion.Euler(shake, shake * 0.5f, 0);
|
||||
|
||||
Quaternion targetRot = OriginalWristRotation * Quaternion.Euler(WristRotationOffset) * shakeRotation;
|
||||
|
||||
@@ -225,11 +225,21 @@ public class DiapasonEquipmentManager : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
ArmEquipment equipment = _armsSystem.GetArmEquipment(_equipmentArmIndex);
|
||||
if (equipment != null)
|
||||
TapAnimationSettings tapSettings = null;
|
||||
if (_spawnedDiapason != null)
|
||||
{
|
||||
equipment.PlayTapAnimation();
|
||||
equipment.StartShake();
|
||||
EquippableTapSettings equippable = _spawnedDiapason.GetComponent<EquippableTapSettings>();
|
||||
if (equippable != null)
|
||||
{
|
||||
tapSettings = equippable.TapSettings;
|
||||
}
|
||||
}
|
||||
|
||||
ArmEquipment equipment = _armsSystem.GetArmEquipment(_equipmentArmIndex);
|
||||
if (equipment != null && tapSettings != null)
|
||||
{
|
||||
equipment.PlayTapAnimation(tapSettings);
|
||||
equipment.StartShake(tapSettings);
|
||||
}
|
||||
|
||||
if (_tapSound != null && _audioSource != null)
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
using UnityEngine;
|
||||
using Unheimlich.Gameplay.Player;
|
||||
|
||||
public class SecurityCameraController : MonoBehaviour
|
||||
{
|
||||
[Header("Tracking Settings")]
|
||||
[SerializeField] private float _trackingDistance = 10f;
|
||||
[SerializeField] private float _rotationSpeed = 2f;
|
||||
[SerializeField] private Transform _pivotPoint;
|
||||
|
||||
[Header("LED Settings")]
|
||||
[SerializeField] private MeshRenderer _ledRenderer;
|
||||
[SerializeField] private float _blinkSpeed = 2f;
|
||||
[SerializeField] private float _minSmoothness = 0f;
|
||||
[SerializeField] private float _maxSmoothness = 0.5f;
|
||||
|
||||
private CharacterController _playerController;
|
||||
private Material _ledMaterial;
|
||||
private float _blinkTimer;
|
||||
private bool _isTracking;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (PlayerController.Instance != null)
|
||||
_playerController = PlayerController.Instance.GetComponent<CharacterController>();
|
||||
|
||||
if (_ledRenderer != null)
|
||||
{
|
||||
_ledMaterial = _ledRenderer.material;
|
||||
}
|
||||
|
||||
if (_pivotPoint == null)
|
||||
_pivotPoint = transform;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_playerController == null) return;
|
||||
|
||||
float distanceToPlayer = Vector3.Distance(_pivotPoint.position, _playerController.transform.position);
|
||||
_isTracking = distanceToPlayer <= _trackingDistance;
|
||||
|
||||
if (_isTracking)
|
||||
{
|
||||
TrackPlayer();
|
||||
}
|
||||
|
||||
UpdateLedBlink();
|
||||
}
|
||||
|
||||
void TrackPlayer()
|
||||
{
|
||||
Vector3 directionToPlayer = _playerController.transform.position - _pivotPoint.position;
|
||||
|
||||
if (directionToPlayer.sqrMagnitude > 0.001f)
|
||||
{
|
||||
Vector3 forward = -directionToPlayer.normalized;
|
||||
Vector3 right = Vector3.Cross(Vector3.up, forward).normalized;
|
||||
Vector3 up = Vector3.Cross(forward, right);
|
||||
|
||||
Quaternion targetRotation = Quaternion.LookRotation(up, forward);
|
||||
_pivotPoint.rotation = Quaternion.Slerp(_pivotPoint.rotation, targetRotation, Time.deltaTime * _rotationSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateLedBlink()
|
||||
{
|
||||
if (_ledMaterial == null) return;
|
||||
|
||||
_blinkTimer += Time.deltaTime * _blinkSpeed;
|
||||
|
||||
float smoothness = Mathf.Lerp(_minSmoothness, _maxSmoothness, Mathf.PingPong(_blinkTimer, 1f));
|
||||
|
||||
_ledMaterial.SetFloat("_Smoothness", smoothness);
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_ledMaterial != null)
|
||||
Destroy(_ledMaterial);
|
||||
}
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
if (_pivotPoint == null)
|
||||
_pivotPoint = transform;
|
||||
|
||||
Gizmos.color = Color.yellow;
|
||||
Gizmos.DrawWireSphere(_pivotPoint.position, _trackingDistance);
|
||||
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawLine(_pivotPoint.position, _pivotPoint.position + _pivotPoint.forward * 2f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17a573927733b4343acc662995710bc2
|
||||
Reference in New Issue
Block a user