rigidBody is heading to a slightly different angle to where im calculating it would be using Reflect


I have a (maybe noob) question... (In JS btw)

I have a sphere collider(with a moveable rigidBody attached) hitting the flat edge of a box collider(with IsKinematic rigidBody attached).

ShotDirection is a unit direction vector, so therefore, so should be whiteBallFollowOnDir.

I am calculating the RayCastHit with:

sphereCastDidCollide = Physics.SphereCast(whiteBall.transform.position, whiteBallRadius, shotDirection, hit, 100, layerMask);

I take the hit.point, then use the hit.normal to get the opposite(reflected) direction vector that would happen had shotDirection collided at hit.point (NB:Is this basic vectors assumption correct?)

whiteBallFollowOnDir = Vector3.Reflect(shotDirection, hit.normal);

I also calculate a reference point along the hit.normal for where the white ball would be when it collides with the cushion, with:

refPositionFromNormal = hit.point + (hit.normal * whiteBallRadius);

I am calculating all these, in order to draw some guide lines on a pool game, that would give a rough(short line) indication of which direction the white ball will bounce off too.

In order to draw these lines, I use a lineRender, I set point 0 of the lineRender to be refPositionFromNormal, and point 1 to be that whiteBallFollowOnDir vector I have calculated previously, multiplied by an arbitrary length.

whiteBallFollowOnVector = whiteBallFollowOnDir * 10;


My question is.. does everything I am doing look right? As the whiteBallFollowOnVector lineRender is ever so close to the actual direction the ball bounces off to, but is just slightly out(shallower).

Is my maths correct and there something else I should be looking for. eg. would AngularDrag cause something like that(its set to 0 btw). Static friction of the ball collider/cushion colliders? drag of the table? air friction? (all of these are set to 0).

The only settings that arent 0 on these 2 colliders and Physics Materials, is: Cushion Physics Material, Bounciness = 0.804. Ball Physics Material, Bounciness = 0.98.

These are set to these values for the 'feel' of the game mechanics. But they shouldnt be affecting the simple vector theory should they?

I'm just wondering what else I could look into(providing theres nothing wrong with my maths/theory).

Thanks in advance, Glenno

p.s. sorry, that turned out longer that i'd hoped.

The "bounciness" is probably the problem. It is the amount of energy conserved by the bounce, so a value < 1 loses energy. If it was 0 then the sphere wouldn't bounce at all and would just slide along the plane of contact.