# Find a point at a distance from point on a line passing through two points

That’s quite a mouthful there but it’s basically it. I would like to add a force to an object in a direction of a touch passing through the center of the object. Basically bouncing a ball. If you touch its edge it will “get kicked harder” than if you touch it closer to the middle.

Currently I am using a Raycast but this doesn’t really do the trick. Any ideas fellow Unitarians?

``````if (Input.GetMouseButtonUp(0)) {
RaycastHit hit;
if(Physics.Raycast(new Vector3(ballCollider2D.center.x,ballCollider2D.center.y,0),
new Vector3(Input.mousePosition.x,Input.mousePosition.y,0),out hit,300f))
{
Vector2 jumpPosition = new Vector2(hit.transform.position.x,hit.transform.position.y);
print("Ray: " + hit);

rigidbody2D.velocity = Vector2.zero;

}
}
``````

Edit:
OK guys, let me clarify, how would I get it to work and hit something?
There is a background behind it, but it returns `false`.

hit.transform.position + (ballCollider2D.center - hit.transform.position) * .5f is a point on the middle of the line connecting the two points.

hit.transform.position + (ballCollider2D.center - hit.transform.position) * .3f is 30 % away from hit.transform.position.

hit.transform.position + (ballCollider2D.center - hit.transform.position).normalized * distance is on the line, distance away from hit.transform.position.