- Home /
Physics in 2d arkanoid. Tangential and normal velocity
2d arkanoid, we have 1 ball. It is necessary to randomly set its normal and tangential velocity at the beginning. I couldn't figure out the physics. If you look at the formulas, then the normal velocity is as follows:
float radius = Random.range(0.5f, 3f);
float normalVelocity = Mathf.Pow(rigidbody2d.velocity, 2) / radius
Even if I found the normal and tangential velocity, how do I apply this to the ball in unity? So far, I've only thought of
rigidbody2d.velocity = new Vector2(normalVelocity, tangentialVelocity );
Answer by petur · Dec 21, 2021 at 03:38 PM
rigidbody2d.velocity is just the velocity on each axis
I don't see the need to get the concepts of tangential and normal velocity involved, since the ball is going to move in a straigth line (right?).
You either need an angle and a single velocity or the velocity in each axis.
Example angle and velocity:
float angle = Random.Range(-45f,45f);
angle = (angle * Mathf.PI) / 180f; // convert degrees to radians
float speed = Random.Range(2f,3f);
float horizontalSpeed = Mathf.Cos(angle) * speed:
float verticalSpeed = Matf.Sin(angle) * speed;
rigidbody2d.velocity = new Vector2( horizontalSpeed, verticalSpeed );
Your answer
Follow this Question
Related Questions
AddForce vs Velocity issues with Rigidbody2D 2 Answers
Velocity Movement & Physics Interactions by Rigidbody2D 0 Answers
How can I make 2D movement less jerky on a controller, with velocity and such? 0 Answers
Inconsistent Rigidbody2D velocity. 0 Answers
How does the velocity of a ball flying throw a portal change when the portal is rotated? 2 Answers