Camera Positioning Relative to an Object by Kira Vakaan19th Jan 2009 19:59
|
---|
Summary Use this function to position and rotate a camera relative to an object's position and rotation. Description Syntax: Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com function CameraFollowObject(Camera,Object,FollowX#,FollowY#,FollowZ#,XAng#,Yang#,ZAng#) xpos#=object position x(Object)+(FollowZ#*cos(object angle x(Object))+FollowY#*sin(object angle x(Object)))*sin(object angle y(Object))+FollowX#*cos(object angle y(Object)) ypos#=object position y(Object)-FollowZ#*sin(object angle x(Object))+FollowY#*cos(object angle x(Object)) zpos#=object position z(Object)+(FollowZ#*cos(object angle x(Object))+FollowY#*sin(object angle x(Object)))*cos(object angle y(Object))-FollowX#*sin(object angle y(Object)) position camera Camera,xpos#,ypos#,zpos# set camera to object orientation Camera,Object pitch camera down Camera,XAng# turn camera right Camera,YAng# roll camera left Camera,ZAng# endfunction |