- Home /
How to maintain magnitude of velocity (otherwise known as speed) after collision
Making pong clone. Ball needs to have the same speed pre and post collision. The ball game object has a rigid body and a physics material. All friction/drag setting are set to zero, bounciness of the material is at 1 (All objects it interacts with also have the same material). The ball still loses speed after a collision, albeit very little.
Sorry if its a duplicate of my previous question, but for some reason I can't find it via search and its not appearing under the questions section of my user-page.
You can always explicitly set the velocity in FixedUpdate():
rigidbody.velocity = rigidbody.velocity.normalized * speed;
Answer by MichelSeguinACCT · May 14, 2017 at 04:43 PM
Extremely late reply (4 years later) , but the answer to this problem for anyone else finding this by googling:
ever update, if your velocity is above zero, do this: rgd.velocity = (Vector2)(rgd.velocity / rgd.velocity.magnitude * startMagnitude);
// Where startMagnitude is the magnitude of velocity you start off with.
Your answer
Follow this Question
Related Questions
Pushing lower of two stacked cubes, and top cube stays still? 1 Answer
Ball Bounciness problem 0 Answers
RigidBody.AddForce causes capsule collider to trip on a surface with friction 2 Answers
Tracked Ride Physics Simulation 0 Answers
How do you attach moving parts (moved by physics) to an animated character? (Secondary Animations) 1 Answer