# Detecting where knife(object) is being hit and add score according to that.....

I have been working on the 2d game where player has to hit the knife on the target and and if knife hit on exact center he will get bonus points and get lower if hit else where…so how would i achieve that any suggestions?

Get hit coordinates and compare them to the coordinates of the center of the target. If they’re close enough to each other, then the player hit the center.

You can score rings as well by just determining the radius of the rings and apply a score of lessening value outwards by determining the distance from center coords and finding which set of radii it is between. You could score the rings from the center out as for example 100, 80, 60, 40, 20 to even it out or 100, 50, 25, 12, 5 for a different scoring gradient.

Yep, like ippdev says, this is basically a distance check from center.

thankyou @ippdev and @neginfinity for the suggestions…i will try your solutions…right now i have applied colliders solution but its not working properly…because my targets are on left and right side of the 2d plane

What do you mean “not working properly”? Does the knife nor stick in? If so you have to fake that. Other than that you have a target. Create collider to match target geometry. Throw knife and get the contact point position and compare to the center position of the target hit.

1 Like