+1 vote

I have a player, and I want the camera to be at the closest point of Path node Curve3D relative to the player origin. Could you give me a basic sample code, how can I implement this? Thanks in advance!

in Engine by (27 points)

1 Answer

+1 vote

You can use Curve3D.get_closest_point() to get the closest point on the path.

by (16 points)

is there an easy way to get the index of the closest point?

I was wondering this as well ^

The curve is baked from a set of points along a Bézier curve, so get_closest_point returns a point along that curve. This point does not need to be a control point. You can try to get the closest offset and search through the control points and compare their offsets. The closest offset should be the closest control point.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.