I’m attempting to determine the speed of ball A after collision which is V2.A as seen within the determine. I do know that the speed of ball A when collision happens is perpendicular to the road connecting centre of ball A and B when the collision happens.

Challenge is, my V2.A is usually flipped in other way, and I am unable to appear to determine the problem right here. This is my V2.A calculation

``````Vector2 diff = (b - a).normalized;
Vector2 perpendiular = Vector2.Perpendicular(diff);
``````

Thanks!

Returns the 2D vector perpendicular to this 2D vector. The result’s at all times rotated 90-degrees in a counter-clockwise path for a 2D coordinate system the place the constructive Y axis goes up.

On this case, simply decide whether or not the unsigned angle between the speed vector of ball A and the end result vector is larger than 90 levels:

``````Vector2 diff = (b - a).normalized;
Vector2 perpendiular = Vector2.Perpendicular(diff);
if (Vector2.Angle(directionOfA, perpendiular) > 90)
{
perpendiular = -perpendiular;
}
``````