本文整理汇总了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));
}
}
示例2: Start
void Start()
{
//startingPosition = transform.position;
rb2d = GetComponent<Rigidbody2D>();
rb2d.AddRelativeForce((Vector2.left * force), ForceMode2D.Impulse);
//Destroy(gameObject, 15);
}
示例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);
}
}
}
}
示例4: InitBullet
void InitBullet()
{
rb2D = GetComponent<Rigidbody2D>();
maxSpeed = 250;
rb2D.AddRelativeForce(direction * maxSpeed);
currentLife = lifespan;
damage = 1;
}
示例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);
}
}
示例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);
}
}
}
示例7: Start
// Use this for initialization
void Start () {
myRigidBody = GetComponent<Rigidbody2D>();
myRigidBody.AddRelativeForce(Vector3.right * projectileSpeed);
myRigidBody.AddTorque(torque);
}
示例8: KillOrthogonalVelocity
void KillOrthogonalVelocity(Rigidbody2D tyre)
{
Vector2 relVel = GetLocalVelocity(tyre);
relVel.y = 0f;
tyre.AddRelativeForce(-relVel * tyre.mass, ForceMode2D.Impulse);
}