0 votes

Hello, as the tile says I'm looking for a curve3D function which, given a 3D points belonging to the curve, returns the tangent vector of the curve at this point. Ideally, this would be a unit vector.

Do you know if a function like this is available? I looked in the docs but didn't find something usefull. I don't really understand the definition of the up vectors...

If I don't find solution, I plan to make a vector with an another point close to the first one, but it is not perfect...

Thanks for your answers, I'll appreciate all of them !

See you ! Simon

in Engine by (21 points)

1 Answer

+1 vote
Best answer

I think if you want the tangent of two baked points, you would need to derive it yourself.
One way to do this is to take two points slightly off from the point you want, take their difference, normalize it and you should obtain a vector looking along the curve at that point (either forward or backward depending on the order you sampled the points). If that's what you expect a tangent to be :p

var point = curve.interpolate_baked(offset)
var point2 = curve.interpolate_baked(offset + 0.001)
var dir = (point2 - point).normalized()
by (29,042 points)
selected by

Yeah, I'll try that way which seems to be the best for me too!

Thanks :)

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.