当前位置: 首页>>代码示例>>C#>>正文


C# ForceMode类代码示例

本文整理汇总了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;

        }
    }
开发者ID:razlani,项目名称:2d_platformer_unity,代码行数:27,代码来源:Misc.cs

示例2: OnReset

 public override void OnReset()
 {
     if (force != null) {
         force.Value = Vector3.zero;
     }
     forceMode = ForceMode.Force;
 }
开发者ID:rjchart,项目名称:Project_YSS_2D,代码行数:7,代码来源:AddRelativeForce.cs

示例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);
 }
开发者ID:andrewberthold,项目名称:Trajectory-Extension-Methods,代码行数:18,代码来源:Trajectory.cs

示例4: OnReset

 public override void OnReset()
 {
     targetGameObject = null;
     force = Vector3.zero;
     position = Vector3.zero;
     forceMode = ForceMode.Force;
 }
开发者ID:HaoYunSun,项目名称:TEMPORAIRE,代码行数:7,代码来源:AddForceAtPosition.cs

示例5: Reset

 public override void Reset()
 {
     this.center = null;
     this.upwardsModifier = 0f;
     this.forceMode = ForceMode.Force;
     this.everyFrame = false;
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:7,代码来源:Explosion.cs

示例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);
    }
开发者ID:Headgate2,项目名称:-mobile-games-pipeline,代码行数:32,代码来源:PhysicsExtensions.cs

示例7: Reset

 public override void Reset()
 {
     center = null;
     upwardsModifier = 0f;
     forceMode = ForceMode.Force;
     everyFrame = false;
 }
开发者ID:personal-robots,项目名称:storyspace,代码行数:7,代码来源:Explosion.cs

示例8: Damage

 public Damage(MonoBehaviour pAttacker, DamageType pDamageType, int pDamage, Vector3 pMomentum, ForceMode pMomentumType)
 {
     attacker = pAttacker;
     damageType = pDamageType;
     damage = pDamage;
     momentum = pMomentum;
     momentumType = pMomentumType;
 }
开发者ID:rghassem,项目名称:Code,代码行数:8,代码来源:Damager.cs

示例9: OnReset

 public override void OnReset()
 {
     targetGameObject = null;
     if (force != null) {
         force.Value = Vector3.zero;
     }
     forceMode = ForceMode.Force;
 }
开发者ID:dev-celvin,项目名称:DK,代码行数:8,代码来源:AddForce.cs

示例10: Reset

 public override void Reset()
 {
     gameObject = null;
     center = new FsmVector3 { UseVariable = true };
     upwardsModifier = 0f;
     forceMode = ForceMode.Force;
     everyFrame = false;
 }
开发者ID:Streek,项目名称:FSM-Action-Collection-for-UN-PM,代码行数:8,代码来源:AddExplosionForce.cs

示例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);
         }
     }
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:58,代码来源:clsragdolljolturgent.cs

示例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;
 }
开发者ID:xclouder,项目名称:godbattle,代码行数:9,代码来源:ExplosionForce.cs

示例13: OnReset

 public override void OnReset()
 {
     targetGameObject = null;
     explosionForce = 0;
     explosionPosition = Vector3.zero;
     explosionRadius = 0;
     upwardsModifier = 0;
     forceMode = ForceMode.Force;
 }
开发者ID:dev-celvin,项目名称:DK,代码行数:9,代码来源:AddExplosionForce.cs

示例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;
 }
开发者ID:sirerr,项目名称:ihateblobs,代码行数:11,代码来源:AddTorque.cs

示例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;
 }
开发者ID:xclouder,项目名称:godbattle,代码行数:11,代码来源:AddTorque.cs


注:本文中的ForceMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。