Version: 2017.4
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Physics.ClosestPoint

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static method ClosestPoint(point: Vector3, collider: Collider, position: Vector3, rotation: Quaternion): Vector3;
public static Vector3 ClosestPoint(Vector3 point, Collider collider, Vector3 position, Quaternion rotation);

Parameters

pointLocation you want to find the closest point to.
colliderThe collider that you find the closest point on.
positionThe position of the collider.
rotationThe rotation of the collider.

Returns

Vector3 The point on the collider that is closest to the specified location.

Description

Returns a point on the given collider that is closest to the specified location.

Note that in case the specified location is inside the collider, or exactly on the boundary of it, the input location is returned instead.

The collider can only be BoxCollider, SphereCollider, CapsuleCollider or a convex MeshCollider.

See Also: ClosestPoint.

Did you find this page useful? Please give it a rating: