當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。