- Home /
The question is answered, right answer was accepted
Physics2D simulation is not taking into acount the material's Friction
I'm currently working in a 2d ball game and I need to show the trajectory of the ball before being thrown. To achieve that, I clone my scene and run a simulation using PhysicsScene2D.Simulate(Time.fixedDeltaTime) The problem is that the simulation is not taking into consideration the lost of momentum due to the friction during the collisions and it's not accurate. I realized that if I set the friction of the ball to 0, or if I disable the rotation in the Z axis from the rigidbody2D, the simulation is completely accurate. Unfortunately, I need to have friction and I need the simulation to work with it, is it possible?
I'm using Unity 2020.3.29f1
The dotted line is the calculated trajectory, the solid line is the actual movement of the ball.
Answer by DavidMontoyaJD · Apr 01 at 02:51 PM
The problem was that I was setting the Inertia of the ball to 0. after removing that line in the code, the simulation and the real-time game behave exactly the same.
Follow this Question
Related Questions
Unity2D raycast to check for a wall, Issues. ~Still not solved...Anybody?~ 2 Answers
How to avoid frictionless surface in 2D collision? 2 Answers
Predict next rigidbody position based on velocity 1 Answer
How do I make my sprite change it's rotation based on the slope it's is on? 2 Answers
What is the best way to implement physic simulation prediction for AI in Unity? 1 Answer