I know this isn't exactly the "correct" way to find collision points since there could be 1 OR 2 (Not 0 though because the collision is guaranteed) but I wanted to just try it out and see how it rolls out, so I created 3 spheres and 2 of the points (Each point is supposed to represent a collision point between 2 spheres) are way out of where they should be, as if I got the direction vector to be opposite of what it needed to be... here's my Lua code:
local function getDist(s1, s2)
local s1_Pos = (s2.Position - s1.Position).unit * s1.Size.X * .5
local s2_Pos = (s1.Position - s2.Position).unit * s2.Size.X * .5
return s1_Pos:Lerp(s2_Pos, .5)
end
- What is wrong with this code?
- How can I find the collision point(s) of 2 spheres?
I read a few questions on StackOverflow but most were either irrelevant or just didn't seem to make sense.