浏览代码

Added Instigator to RigidbodyAction

/main
Thomas ICHÉ 5 年前
当前提交
6b12c48b
共有 1 个文件被更改,包括 17 次插入7 次删除
  1. 24
      Runtime/LevelScripting/Actions/RigidbodyAction.cs

24
Runtime/LevelScripting/Actions/RigidbodyAction.cs


[ExecuteAlways]
public class RigidbodyAction : ActionBase
{
public bool ApplyOnInstigator = false;
[HideIf("ApplyOnInstigator")]
public Rigidbody m_Rigidbody;
[OnValueChanged("OnParameterTypeChanged")]
public RigidbodyActionType actionType;

public override void Execute(GameObject instigator = null)
{
if (m_Rigidbody == null)
Rigidbody target = m_Rigidbody;
if (ApplyOnInstigator)
target = instigator.GetComponent<Rigidbody>();
if (target == null)
{
Debug.LogWarning("Could not apply RigidbodyAction to null Rigidbody");
}
switch (actionType)
{

m_Rigidbody.AddForce(direction, forceMode);
target.AddForce(direction, forceMode);
m_Rigidbody.AddRelativeForce(direction, forceMode);
target.AddRelativeForce(direction, forceMode);
m_Rigidbody.AddTorque(direction, forceMode);
target.AddTorque(direction, forceMode);
m_Rigidbody.AddRelativeTorque(direction, forceMode);
target.AddRelativeTorque(direction, forceMode);
m_Rigidbody.AddExplosionForce(explosionForce, explositonPosition, explosionRadius, 0, forceMode);
target.AddExplosionForce(explosionForce, explositonPosition, explosionRadius, 0, forceMode);
m_Rigidbody.Sleep();
target.Sleep();
break;
}
}

正在加载...
取消
保存