“Velocity Rigidbody” Réponses codées

comment régler la vitesse de la body rigid dans l'unité

//Set Velocity to a certain speed
[SerializeField] private float maxSpeed = 10;
[SerializeField] private Rigidbody rb;

void FixedUpdate() {
  if(rb.velocity.magnitude > maxSpeed) {
    rb.velocity = rb.velocity.normalized * maxSpeed;
  }
}
Mysterious Marten

Unity Comment définir la vitesse de rigidbody

Vector3 velocity = new Vector3(10f/*x*/, 10f/*y*/, 10f/*z*/);
GetComponent<Rigidbody>().velocity = velocity;
Modern Mink

Velocity rigidbody C # Unity

//for rigidbody2D
GetComponent<Rigidbody2D>().velocity =new Vector2(40,0);
Charming Copperhead

Velocity Rigidbody

rb.velocity = new Vector3(0, 10, 0);
Clever Curlew

comment diminuer la vitesse d'un corps rigide d'unité

//Drecrese Rigidbody Speed
[SerializeField] private Rigidbody rb;

void FixedUpdate() {
  //Decrease speed
  rb.velocity -= rb.velocity * 0.1f;
}
Mysterious Marten

rigidbody.velocity.magnitude

//speed of rigidbody in m/s
float speed = rigidbody.velocity.magnitude;
MunchDuster

Réponses similaires à “Velocity Rigidbody”

Questions similaires à “Velocity Rigidbody”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code