Question by
Yemnefer · Sep 22, 2017 at 02:40 AM ·
rigidbody2dfloatconvertangularvelocityzero
Angular Velocity to zero
I can't set the angular.velocity to zero... Why ?
if (Input.GetAxisRaw ("Vertical") > 0.5f || Input.GetAxisRaw("Vertical") < -0.5f)
{
v = Input.GetAxis ("Vertical");
//moving the player
rb2d.velocity = new Vector2(h * speed, v * speed);
//limiting the player speed
if (rb2d.velocity.y > maxSpeed) {
rb2d.velocity = new Vector2 (rb2d.velocity.x, maxSpeed);
}
if (rb2d.velocity.y < -maxSpeed) {
rb2d.velocity = new Vector2 (rb2d.velocity.x, -maxSpeed);
}
isMoving = true;
lastMove = new Vector2 (0f, Input.GetAxisRaw ("Vertical"));
//trying to stop the player when he releases the axis
if (Input.GetAxisRaw ("Vertical") == 0f) {
rb2d.Sleep ();
rb2d.velocity = Vector2.zero;
rb2d.angularVelocity = Vector2.zero;
}
}
Comment
Your answer
Follow this Question
Related Questions
Convert "Double" to "Float" or "Int"? 1 Answer
Rigidbody2D angular velocity is zero after I set it to a float that's not zero 1 Answer
Color float rgb values cannot be converted correctly to int, and hex. 1 Answer
How to convert float to long 4 Answers
How control Rigidbody2d using GetAxis with AddForce and angularVelocity (2D) 1 Answer