|
|
|
|
|
|
[ExecuteAlways] |
|
|
|
public class RigidbodyAction : ActionBase |
|
|
|
{ |
|
|
|
public Rigidbody rb; |
|
|
|
public Rigidbody m_Rigidbody; |
|
|
|
[OnValueChanged("OnParameterTypeChanged")] |
|
|
|
public RigidbodyActionType actionType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void Execute(GameObject instigator = null) |
|
|
|
{ |
|
|
|
if (rb == null) |
|
|
|
if (m_Rigidbody == null) |
|
|
|
return; |
|
|
|
|
|
|
|
switch (actionType) |
|
|
|
|
|
|
{ |
|
|
|
rb.AddForce(direction, forceMode); |
|
|
|
m_Rigidbody.AddForce(direction, forceMode); |
|
|
|
rb.AddRelativeForce(direction, forceMode); |
|
|
|
m_Rigidbody.AddRelativeForce(direction, forceMode); |
|
|
|
rb.AddTorque(direction, forceMode); |
|
|
|
m_Rigidbody.AddTorque(direction, forceMode); |
|
|
|
rb.AddRelativeTorque(direction, forceMode); |
|
|
|
m_Rigidbody.AddRelativeTorque(direction, forceMode); |
|
|
|
rb.AddExplosionForce(explosionForce, explositonPosition, explosionRadius, 0, forceMode); |
|
|
|
m_Rigidbody.AddExplosionForce(explosionForce, explositonPosition, explosionRadius, 0, forceMode); |
|
|
|
rb.Sleep(); |
|
|
|
m_Rigidbody.Sleep(); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
force = false; |
|
|
|
explosion = false; |
|
|
|
explosion = (actionType == RigidbodyActionType.ExplosionForce); |
|
|
|
|
|
|
|
switch (actionType) |
|
|
|
{ |
|
|
|
|
|
|
case RigidbodyActionType.Torque: |
|
|
|
force = true; |
|
|
|
break; |
|
|
|
case RigidbodyActionType.ExplosionForce: |
|
|
|
explosion = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |