[Closed] Shoot Ray From Vertex To Object
I have three objects. I want to shoot a ray from a vertex of obj1 to a point helper, and get the intersection where the ray hits obj2.
local [color=white]vertPos = getvert obj1 vertexSelection[i] [/color]– get the position of the vertex on obj1
local rayTarget = obj3.pos – this is the where to shoot the ray at (point helper)
local ShootRay = ray vertPos rayTarget – shoot ray from vert to pointhelper
local TargetVect = intersectRay obj2 ShootRay – try to get point where ray intersects obj2
[color=white]Now TargetVect.pos should hold the vector where the ray hit obj2’s surface.[/color]
I think rayTarget must be a direction, but how can I get a direction from the vert to the point helper that will work?
Thanks for any suggestions.
local [color=white]vertPos = getvert obj1 vertexSelection[i] [/color]– get the position of the vertex on obj1
local rayTarget = normalize (obj3.pos – vertPos) – this is the where to shoot the ray at (point helper)
local ShootRay = ray vertPos rayTarget – shoot ray from vert to pointhelper
local TargetVect = intersectRay obj2 ShootRay – try to get point where ray intersects obj2
if TargetVect != undefined do format “Hit Object 2 at %
” TargetVect.pos
Thanks Bobo, that is exactly what I was looking for! I really appreciate your help.