We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 39c7c08 commit ba03d6fCopy full SHA for ba03d6f
Logic/BallLogic.cs
@@ -95,6 +95,13 @@ public void handleBallColission(BallLogic other)
95
float collisionPulse = 2 * this.Mass * other.Mass * Vector2.Dot(relativeVelocity, collisionNormal) / (this.Mass + other.Mass);
96
this.Velocity += collisionPulse / this.Mass * collisionNormal;
97
other.Velocity -= collisionPulse / other.Mass * collisionNormal;
98
+
99
+ float overlapDistance = (this.Radius / 2 + other.Radius / 2) - Vector2.Distance(this._ball.Position, other._ball.Position);
100
+ if (overlapDistance > 0)
101
+ {
102
+ this._ball.Position -= collisionNormal * overlapDistance / 2;
103
+ other._ball.Position += collisionNormal * overlapDistance / 2;
104
+ }
105
}
106
107
0 commit comments