Camera collisions using the distance formula by GMX14th Nov 2005 13:16
|
---|
Summary This function will return whether a specified object is "colliding" with the camera. This allows for not having to type the distance formula again and again and is good f Description In reality, there is no collision checked between the camera and the object, but rather the distance between the object specified (objname) and the camera point is figured by the function. Then it checks to see if the distance is under the threshold amount. If so, it returns 1. So you could easily type Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com function cameracollision(objname,threshold) if object exist (objname) dx#=camera position x(0)-object position x(objname) dy#=camera position y(0)-object position y(objname) dz#=camera position z(0)-object position z(objname) dist#=abs(sqrt(abs(dx#*dx#)+abs(dy#*dy#)+abs(dz#*dz#))) endif if dist#<threshold and object exist (objname) col=1 else col=0 endif endfunction col |