• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ForceMode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ForceMode的典型用法代码示例。如果您正苦于以下问题:C# ForceMode类的具体用法?C# ForceMode怎么用?C# ForceMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ForceMode类属于命名空间,在下文中一共展示了ForceMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: ForceToPoint

 public void ForceToPoint(Vector3 point, float maxForce, float maxDistance, bool inverseDirection, ForceMode mode)
 {
     Vector3 myPosition = myTransform.position;
     float distance = Vector3.Distance(myPosition, point);
     if (distance <= maxDistance) {
         Vector3 direction = (point - myPosition);
         if (inverseDirection) {
             direction *= -1;
         }
         myRigidbody.AddForce(direction.normalized * (1f - distance / maxDistance) * maxForce, mode);
     }
 }
开发者ID:GoncaloBFM,项目名称:Gravity,代码行数:12,代码来源:PhysicalScript.cs


示例17: OnReset

 public override void OnReset()
 {
     if (explosionForce != null) {
         explosionForce.Value = 0;
     }
     if (explosionPosition != null) {
         explosionPosition.Value = Vector3.zero;
     }
     if (explosionRadius != null) {
         explosionRadius.Value = 0;
     }
     upwardsModifier = 0;
     forceMode = ForceMode.Force;
 }
开发者ID:TrojanFighter,项目名称:U3D-DesignerBehaviorTest1,代码行数:14,代码来源:AddExplosionForce.cs


示例18: AddExplosionForce

 public static void AddExplosionForce ( 
     this Rigidbody body
     , float explosionForce
     , Vector3 explosionRadiusCenter
     , float explosionRadius
     , Vector3 explosionOriginPoint // this is the oposite from upwardsModifier
     , ForceMode mode
 )
 {
     if (Vector3.Distance(body.transform.position, explosionRadiusCenter) <= explosionRadius) 
     {
         Vector3 force = (body.transform.position - (explosionRadiusCenter + explosionOriginPoint));
         body.AddForce(force * (explosionForce/5), mode); // 5 came from experimentation
     }
 }
开发者ID:timKofoed,项目名称:MatchShooter,代码行数:15,代码来源:PPFXRigidBodyExtensions.cs


示例19: AddForce

	public static void AddForce (this Rigidbody2D rigidbody2D, Vector2 force, ForceMode mode = ForceMode.Force) {

		switch(mode){
		case ForceMode.Force:
			rigidbody2D.AddForce (force);
			break;
		case ForceMode.Impulse:
			rigidbody2D.AddForce (force / Time.fixedDeltaTime);
			break;
		case ForceMode.Acceleration:
			rigidbody2D.AddForce (force * rigidbody2D.mass);
			break;
		case ForceMode.VelocityChange:
			rigidbody2D.AddForce (force * rigidbody2D.mass / Time.fixedDeltaTime);
			break;
		}
	}
开发者ID:Kindpokemon,项目名称:Project-F-GoN-,代码行数:17,代码来源:Physics2DExtensions.cs


示例20: RecieveDamage

 // Recieve damage methods
 #region Recieve Damage methods and overloads
 public virtual void RecieveDamage(GameObject source, int Amount, float KnockbackForce, ForceMode m)
 {
     if (CharacterHealth > 0)
     {
         this.CharacterHealth -= Amount;
         Vector3 relativeDirection = this.transform.position - source.transform.position;
         relativeDirection = relativeDirection.normalized;
         relativeDirection *= KnockbackForce;
         this.transform.rigidbody.AddForce(relativeDirection, m);
         // Visual effect
         if (GetHitEffect)
         {
             Instantiate(GetHitEffect, gotHitPoint, transform.rotation);
         }
         // Sound effect
         DamageTaken(source);
     }
 }
开发者ID:ConnectDeveloper01,项目名称:dorumon,代码行数:20,代码来源:Character.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ForeachStatement类代码示例发布时间:2022-05-24
下一篇:
C# ForStatement类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap