0 votes

I suck at Vector math, so please help me. How do I find a global position of any point along the RayCast if I provide the distance from the origin? So, let's say, the ray is coming from the position of the camera to another position. I want to find out the Vector3 of a global position at 10 units away from the origin along the ray. How do I do it? If it's still confusing, here's a diagram.enter image description here

in Engine by (83 points)

1 Answer

+2 votes
Best answer

If you normalize the cast_to-vector of your RayCast it maintains the same direction, but is shortened (or lengthened) to unit-length. So a point 10 units away from the origin of the ray is simply 10 * $RayCast.cast_to.normalized().

by (10,281 points)
selected by

thank you very much, this works! So simple of a solution, i don't know how I didn't figure this out!

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 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 webmaster@godotengine.org with your username.