浏览代码

Update Camera Shake Behavior, + Changelog

/feature-cinemachine-noise-shake
Thomas ICHÉ 4 年前
当前提交
117652f0
共有 2 个文件被更改,包括 36 次插入30 次删除
  1. 1
      CHANGELOG.md
  2. 65
      Runtime/LevelScripting/Actions/CinemachineCameraShakeAction.cs

1
CHANGELOG.md


* Added Cinemachine Actions:
* `CinemachineSetCameraNoiseAction` : Defines or remove noise for a Virtual Camera
* `CinemachineSetCustomBlendsAction` : Defines custom blends for the Cinemachine Brain of the Virtual Camera Manager
* `CinemachineCameraShakeAction` : Trigger camera shakes for Cinemachine Impulse Sources
## 2020.2.6

65
Runtime/LevelScripting/Actions/CinemachineCameraShakeAction.cs


namespace GameplayIngredients.Actions
{
[RequireComponent(typeof(CinemachineImpulseSource))]
SelfTransform,
RemoteTransform,
Self,
ImpulseSource,
OtherTransform,
[NonNullCheck]
public CinemachineImpulseSource impulseSource;
[Header("Position")]
public ImpulseLocation impulseLocation = ImpulseLocation.SelfTransform;
public ImpulseLocation impulseLocation = ImpulseLocation.Self;
[Tooltip("The Remote transform to use to generate impulses")]
public Transform remoteImpulseLocation;
bool useRemoteTransform => impulseLocation == ImpulseLocation.RemoteTransform;
[Tooltip("The alternate transform to use to generate impulses")]
public Transform otherTransform;
bool useRemoteTransform => impulseLocation == ImpulseLocation.OtherTransform;
public bool LocalSpace = true;
public bool localSpace = true;
[Tooltip("The Impulse Vector to Use")]
public Vector3 baseImpulse = Vector3.up;
[Tooltip("Whether to apply randomness as well")]

[ShowIf(EConditionOperator.And, "randomImpulse", "normalize")]
public Vector2 postNormalizeRemap = Vector2.one;
CinemachineImpulseSource m_ImpulseSource;
if(m_ImpulseSource == null)
if(impulseSource == null)
m_ImpulseSource = GetComponent<CinemachineImpulseSource>();
if (m_ImpulseSource == null)
m_ImpulseSource = gameObject.AddComponent<CinemachineImpulseSource>();
Debug.LogWarning($"CinemachineCameraShakeAction : No Impulse source was provided");
return;
}
Vector3 impulse = baseImpulse;

switch (impulseLocation)
{
default:
case ImpulseLocation.SelfTransform:
if (LocalSpace)
case ImpulseLocation.Self:
if (localSpace)
m_ImpulseSource.GenerateImpulse(impulse);
impulseSource.GenerateImpulseAt(transform.position, impulse);
case ImpulseLocation.RemoteTransform:
if(remoteImpulseLocation != null)
case ImpulseLocation.ImpulseSource:
if (localSpace)
impulse = impulseSource.transform.localToWorldMatrix.MultiplyVector(impulse);
impulseSource.GenerateImpulseAt(impulseSource.transform.position, impulse);
break;
case ImpulseLocation.OtherTransform:
if(otherTransform != null)
if (LocalSpace)
impulse = remoteImpulseLocation.localToWorldMatrix.MultiplyVector(impulse);
if (localSpace)
impulse = otherTransform.localToWorldMatrix.MultiplyVector(impulse);
m_ImpulseSource.GenerateImpulseAt(remoteImpulseLocation.position, impulse);
impulseSource.GenerateImpulseAt(otherTransform.position, impulse);
if (LocalSpace)
if (localSpace)
m_ImpulseSource.GenerateImpulse(impulse);
impulseSource.GenerateImpulse(impulse);
if (LocalSpace)
if (localSpace)
m_ImpulseSource.GenerateImpulseAt(instigator.transform.position, impulse);
impulseSource.GenerateImpulseAt(instigator.transform.position, impulse);
if (LocalSpace)
if (localSpace)
m_ImpulseSource.GenerateImpulse(impulse);
impulseSource.GenerateImpulse(impulse);
}
break;
}

正在加载...
取消
保存