public AddRelativeForce ( |
||
relativeForce | Components of the force in the X and Y axes. | |
mode | [ | The method used to apply the specified force. |
return | void |
// 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)); } }
static public int AddRelativeForce(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 2) { UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l); UnityEngine.Vector2 a1; checkType(l, 2, out a1); self.AddRelativeForce(a1); pushValue(l, true); return(1); } else if (argc == 3) { UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l); UnityEngine.Vector2 a1; checkType(l, 2, out a1); UnityEngine.ForceMode2D a2; checkEnum(l, 3, out a2); self.AddRelativeForce(a1, a2); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function AddRelativeForce to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int AddRelativeForce(IntPtr l) { try{ if (matchType(l, 2, typeof(UnityEngine.Vector2), typeof(UnityEngine.ForceMode2D))) { UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l); UnityEngine.Vector2 a1; checkType(l, 2, out a1); UnityEngine.ForceMode2D a2; checkEnum(l, 3, out a2); self.AddRelativeForce(a1, a2); return(0); } else if (matchType(l, 2, typeof(UnityEngine.Vector2))) { UnityEngine.Rigidbody2D self = (UnityEngine.Rigidbody2D)checkSelf(l); UnityEngine.Vector2 a1; checkType(l, 2, out a1); self.AddRelativeForce(a1); return(0); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
void Start() { //startingPosition = transform.position; rb2d = GetComponent<Rigidbody2D>(); rb2d.AddRelativeForce((Vector2.left * force), ForceMode2D.Impulse); //Destroy(gameObject, 15); }
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); } } } }
void InitBullet() { rb2D = GetComponent<Rigidbody2D>(); maxSpeed = 250; rb2D.AddRelativeForce(direction * maxSpeed); currentLife = lifespan; damage = 1; }
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); } }
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); } } }
// Use this for initialization void Start () { myRigidBody = GetComponent<Rigidbody2D>(); myRigidBody.AddRelativeForce(Vector3.right * projectileSpeed); myRigidBody.AddTorque(torque); }
void KillOrthogonalVelocity(Rigidbody2D tyre) { Vector2 relVel = GetLocalVelocity(tyre); relVel.y = 0f; tyre.AddRelativeForce(-relVel * tyre.mass, ForceMode2D.Impulse); }