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


C# Rigidbody2D.AddRelativeForce方法代码示例

本文整理汇总了C#中UnityEngine.Rigidbody2D.AddRelativeForce方法的典型用法代码示例。如果您正苦于以下问题:C# Rigidbody2D.AddRelativeForce方法的具体用法?C# Rigidbody2D.AddRelativeForce怎么用?C# Rigidbody2D.AddRelativeForce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Rigidbody2D的用法示例。


在下文中一共展示了Rigidbody2D.AddRelativeForce方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

 // Use this for initialization
 void Start()
 {
     r2d = GetComponent<Rigidbody2D> ();
     if(Movimentacao.left){
         r2d.AddRelativeForce (new Vector2 (-speed, 0));
     }else{
         r2d.AddRelativeForce (new Vector2 (speed, 0));
     }
 }
开发者ID:EduBeziaco,项目名称:2Dgame,代码行数:10,代码来源:Bullet.cs

示例2: Start

 void Start()
 {
     //startingPosition = transform.position;
     rb2d = GetComponent<Rigidbody2D>();
     rb2d.AddRelativeForce((Vector2.left * force), ForceMode2D.Impulse);
     //Destroy(gameObject, 15);
 }
开发者ID:9,项目名称:Swordface2.5D,代码行数:7,代码来源:GiraBullet.cs

示例3: Move

    public override void Move(Rigidbody2D movingRB, Rigidbody2D targetRB)
    {
        if (movingRB == null || targetRB == null) { return; }

        if (canDash)
        {
            RotateTowardTarget(movingRB, targetRB);

            //if we're not at max speed, add force
            if (movingRB.velocity.sqrMagnitude < (maxVelocity * maxVelocity * forceMultiplier))
            {
                movingRB.AddRelativeForce(Vector2.right * accelerationForce * forceMultiplier, ForceMode2D.Impulse);
                nextMovementTime = Time.fixedTime + movementDelay;
                isDashing = true;
                canDash = false;

                emitParticles = true;

                if (dashAnimator != null)
                {
                    dashAnimator.SetBool(AnimationParams.IS_CHOMPING, true);
                }
            }
        }
    }
开发者ID:ironpencil,项目名称:critomit,代码行数:25,代码来源:MoveDashTowardTarget.cs

示例4: InitBullet

	void InitBullet()
	{
		rb2D = GetComponent<Rigidbody2D>();
		maxSpeed = 250;
		rb2D.AddRelativeForce(direction * maxSpeed);
		currentLife = lifespan;
		damage = 1;
	}
开发者ID:DreamSea,项目名称:GuiShips,代码行数:8,代码来源:BulletLogic.cs

示例5: Move

    public override void Move(Rigidbody2D movingRB, Rigidbody2D targetRB)
    {
        if (movingRB == null || targetRB == null) { return; }

        //if we're not at max speed, add force
        if (movingRB.velocity.sqrMagnitude < (maxVelocity * maxVelocity * forceMultiplier))
        {
            movingRB.AddRelativeForce(Vector2.right * accelerationForce * forceMultiplier);
        }
    }
开发者ID:ironpencil,项目名称:critomit,代码行数:10,代码来源:MoveForward.cs

示例6: Move

    public override void Move(Rigidbody2D movingRB, Rigidbody2D targetRB)
    {
        if (movingRB == null || targetRB == null) { return; }

        RotateTowardTarget(movingRB, targetRB);

        //if we're not at max speed, add force
        if (movingRB.velocity.sqrMagnitude < (maxVelocity * maxVelocity * forceMultiplier))
        {
            movingRB.AddRelativeForce(Vector2.right * accelerationForce * forceMultiplier);

            int numParticles = UnityEngine.Random.Range((int)minMaxParticles.x, (int)minMaxParticles.y + 1);
            if (numParticles > 0)
            {
                particleSystem.Emit(numParticles);
            }
        }
    }
开发者ID:ironpencil,项目名称:critomit,代码行数:18,代码来源:MoveWaveToTarget.cs

示例7: Start

	// Use this for initialization
	void Start () {
		myRigidBody = GetComponent<Rigidbody2D>();
		myRigidBody.AddRelativeForce(Vector3.right * projectileSpeed);
		myRigidBody.AddTorque(torque);
	}
开发者ID:Greg-Rus,项目名称:HomoPropaganda,代码行数:6,代码来源:ProjectileMovement.cs

示例8: KillOrthogonalVelocity

    void KillOrthogonalVelocity(Rigidbody2D tyre)
    {
        Vector2 relVel = GetLocalVelocity(tyre);
        relVel.y = 0f;

        tyre.AddRelativeForce(-relVel * tyre.mass, ForceMode2D.Impulse);
    }
开发者ID:jabza,项目名称:BusSimulator,代码行数:7,代码来源:Vehicle.cs


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