Hey, So i have been really stuck on how i should go about making something trigger if i look at it / look away in the cameras view… What would be the easiest way?
I was thinking using Raycasts?
Hey, So i have been really stuck on how i should go about making something trigger if i look at it / look away in the cameras view… What would be the easiest way?
I was thinking using Raycasts?
The Dot product is perfect for this sort of thing.
Some pseudo:
Vec3 dirFromMeToObject = (objPos - myPos).normal
Vec3 myCurrentFacingDir = trans.forward
if (Vec3.Dot(dirFromMeToObject, myCurrentFacingDir) > 0)
//object is with a 180 degree arc in front of us
if (Vec3.Dot(dirFromMeToObject, myCurrentFacingDir) > 0.5)
//object is with a 90 degree arc in front of us
if (Vec3.Dot(dirFromMeToObject, myCurrentFacingDir) > 0.75)
//object is with a 45 degree arc in front of us