本文整理汇总了C#中ForceMode类的典型用法代码示例。如果您正苦于以下问题:C# ForceMode类的具体用法?C# ForceMode怎么用?C# ForceMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ForceMode类属于命名空间,在下文中一共展示了ForceMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyForceMode
public Vector2 ApplyForceMode(Vector2 force, ForceMode forceMode)
{
switch (forceMode)
{
case ForceMode.Force:
return force;
case ForceMode.Impulse:
return force / Time.fixedDeltaTime;
case ForceMode.Acceleration:
return force * rigidbody2D.mass;
case ForceMode.VelocityChange:
return force * rigidbody2D.mass / Time.fixedDeltaTime;
default:
return force;
}
}
示例2: OnReset
public override void OnReset()
{
if (force != null) {
force.Value = Vector3.zero;
}
forceMode = ForceMode.Force;
}
示例3: DebugTrajectory
/// <summary>
/// Draws a <seealso cref="Rigidbody" />'s trajectory using <seealso cref="Debug" />.DrawLine.
/// </summary>
/// <param name="rb"> The body whose trajectory is being drawn. </param>
/// <param name="force"> For predicting the effects of a Rigidbody.AddForce() method. Use Vector3.zero if not needed. </param>
/// <param name="mode"> Determines how the force vector changes the velocity. Irrelevant when using Vector3.zero. </param>
/// <param name="color"> The color of the line being drawn. </param>
/// <param name="trajectoryDuration"> Amount of time in seconds to predict. </param>
/// <param name="lineDuration"> Amount of time in seconds the drawn line will persist. </param>
/// <param name="constantForce"> Will the force be applied every FixedUpdate. </param>
/// <param name='depthTest'> Whether or not the line should be faded when behind other objects. </param>
public static void DebugTrajectory(this Rigidbody rb, Vector3 force, ForceMode mode, Color color,
float trajectoryDuration = 1.0f, float lineDuration = 0.0f, bool constantForce = false, bool depthTest = false)
{
var positions = rb.GetTrajectory(force, mode, trajectoryDuration, constantForce);
for (var i = 0; i < positions.Length - 1; i++)
Debug.DrawLine(positions[i], positions[i + 1], color, lineDuration, depthTest);
}
示例4: OnReset
public override void OnReset()
{
targetGameObject = null;
force = Vector3.zero;
position = Vector3.zero;
forceMode = ForceMode.Force;
}
示例5: Reset
public override void Reset()
{
this.center = null;
this.upwardsModifier = 0f;
this.forceMode = ForceMode.Force;
this.everyFrame = false;
}
示例6: AddForce2D
/// <summary>
/// Function for applying a specific type of force to a Rigidbody2D (since the default functionality is incomplete)
/// </summary>
/// <param name="rb2d">Rigidbody2D to apply the force to</param>
/// <param name="force">The amount of force to apply</param>
/// <param name="mode">What type of force to apply</param>
/// <param name="relativeTo">Should the force be applied in the rigidbody's local space, or world space?</param>
public static void AddForce2D(this Rigidbody2D rb2d, Vector2 force, ForceMode mode = ForceMode.Force, Space relativeTo = Space.World)
{
ForceMode2D mode2D = ForceMode2D.Force;
Vector2 forceApplied = force;
switch (mode)
{
case ForceMode.Impulse:
mode2D = ForceMode2D.Impulse;
break;
case ForceMode.Acceleration:
forceApplied *= rb2d.mass;
break;
case ForceMode.VelocityChange:
forceApplied = force * rb2d.mass / Time.fixedDeltaTime;
break;
case ForceMode.Force:
//nothing special
break;
}
if (relativeTo == Space.Self)
rb2d.AddRelativeForce(forceApplied, mode2D);
else if (relativeTo == Space.World)
rb2d.AddForce(forceApplied, mode2D);
}
示例7: Reset
public override void Reset()
{
center = null;
upwardsModifier = 0f;
forceMode = ForceMode.Force;
everyFrame = false;
}
示例8: Damage
public Damage(MonoBehaviour pAttacker, DamageType pDamageType, int pDamage, Vector3 pMomentum, ForceMode pMomentumType)
{
attacker = pAttacker;
damageType = pDamageType;
damage = pDamage;
momentum = pMomentum;
momentumType = pMomentumType;
}
示例9: OnReset
public override void OnReset()
{
targetGameObject = null;
if (force != null) {
force.Value = Vector3.zero;
}
forceMode = ForceMode.Force;
}
示例10: Reset
public override void Reset()
{
gameObject = null;
center = new FsmVector3 { UseVariable = true };
upwardsModifier = 0f;
forceMode = ForceMode.Force;
everyFrame = false;
}
示例11: metjolturgent
private void metjolturgent(float varpforcemin, float varpforcemax, float varptorquemin, float varptorquemax, ForceMode varpforcemode, bool varpjoltspine, bool varpjolthead, bool varpjoltarmleft, bool varpjoltarmright, bool varpjoltlegright, bool varpjoltlegleft)
{
clsurgent componentInChildren = base.gameObject.GetComponentInChildren<clsurgent>();
if (componentInChildren == null)
{
return;
}
Vector3 force = new Vector3(UnityEngine.Random.Range(varpforcemin, varpforcemax), UnityEngine.Random.Range(varpforcemin, varpforcemax), UnityEngine.Random.Range(varpforcemin, varpforcemax));
Vector3 torque = new Vector3(UnityEngine.Random.Range(varptorquemin, varptorquemax), UnityEngine.Random.Range(varptorquemin, varptorquemax), UnityEngine.Random.Range(varptorquemin, varptorquemax));
if (varpjoltspine)
{
for (int i = 0; i < componentInChildren.vargamnodes.vargamspine.Length; i++)
{
componentInChildren.vargamnodes.vargamspine[i].GetComponent<Rigidbody>().AddForce(force, varpforcemode);
componentInChildren.vargamnodes.vargamspine[i].GetComponent<Rigidbody>().AddTorque(torque, varpforcemode);
}
}
if (varpjolthead)
{
for (int j = 0; j < componentInChildren.vargamnodes.vargamhead.Length; j++)
{
componentInChildren.vargamnodes.vargamhead[j].GetComponent<Rigidbody>().AddForce(force, varpforcemode);
componentInChildren.vargamnodes.vargamhead[j].GetComponent<Rigidbody>().AddTorque(torque, varpforcemode);
}
}
if (varpjoltarmleft)
{
for (int k = 0; k < componentInChildren.vargamnodes.vargamarmleft.Length; k++)
{
componentInChildren.vargamnodes.vargamarmleft[k].GetComponent<Rigidbody>().AddForce(force, varpforcemode);
componentInChildren.vargamnodes.vargamarmleft[k].GetComponent<Rigidbody>().AddTorque(torque, varpforcemode);
}
}
if (varpjoltarmright)
{
for (int l = 0; l < componentInChildren.vargamnodes.vargamarmright.Length; l++)
{
componentInChildren.vargamnodes.vargamarmright[l].GetComponent<Rigidbody>().AddForce(force, varpforcemode);
componentInChildren.vargamnodes.vargamarmright[l].GetComponent<Rigidbody>().AddTorque(torque, varpforcemode);
}
}
if (varpjoltlegleft)
{
for (int m = 0; m < componentInChildren.vargamnodes.vargamlegleft.Length; m++)
{
componentInChildren.vargamnodes.vargamlegleft[m].GetComponent<Rigidbody>().AddForce(force, varpforcemode);
componentInChildren.vargamnodes.vargamlegleft[m].GetComponent<Rigidbody>().AddTorque(torque, varpforcemode);
}
}
if (varpjoltlegright)
{
for (int n = 0; n < componentInChildren.vargamnodes.vargamlegright.Length; n++)
{
componentInChildren.vargamnodes.vargamlegright[n].GetComponent<Rigidbody>().AddForce(force, varpforcemode);
componentInChildren.vargamnodes.vargamlegright[n].GetComponent<Rigidbody>().AddTorque(torque, varpforcemode);
}
}
}
示例12: Reset
public override void Reset () {
explosionPoint = new ConcreteVector3Var();
explosionPosition = new ConcreteGameObjectVar(this.self);
explosionForce = new ConcreteFloatVar();
explosionRadius = new ConcreteFloatVar();
upwardsModifier = new ConcreteFloatVar();
mode = ForceMode.Force;
layers = -1;
}
示例13: OnReset
public override void OnReset()
{
targetGameObject = null;
explosionForce = 0;
explosionPosition = Vector3.zero;
explosionRadius = 0;
upwardsModifier = 0;
forceMode = ForceMode.Force;
}
示例14: Reset
public override void Reset()
{
gameObject = null;
// default axis to variable dropdown with None selected.
x = new FsmFloat { UseVariable = true };
y = new FsmFloat { UseVariable = true };
z = new FsmFloat { UseVariable = true };
space = Space.World;
forceMode = ForceMode.Force;
everyFrame = false;
}
示例15: Reset
public override void Reset () {
gameObject = new ConcreteGameObjectVar(this.self);
space = Space.World;
torque = new ConcreteVector3Var();
torqueX = new ConcreteFloatVar();
torqueY = new ConcreteFloatVar();
torqueZ = new ConcreteFloatVar();
multiplyTorqueBy = new ConcreteFloatVar();
mode = ForceMode.Force;
perSecond = true;
}