I have never seen a function constructed like this first line.
I can’t find another example.
- Can someone explain it to me? …Especialy the
: Vector3
at the end?
function getSurfaceFacingDirection(surfacePointFrom: Vector3, surfacePointTo: Vector3): Vector3
local translation = surfacePointTo - surfacePointFrom
local translateDir = translation.Unit --This goes through the sphere. We want this, except perpendicular to the surface normal.
local surfaceNormal = (surfacePointFrom - ball.Position).Unit
local rightVector = translateDir:Cross(surfaceNormal) --This will be perpendicular to surface normal *and* the facing direction
local facingDirection = rightVector:Cross(surfaceNormal) --This will be perpendicular to surface normal and rightVector. That means it's out result!
return facingDirection.Unit
end
Thanks…