View Single Post
Old
Mr Kidnapper
Senior Member
 
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 02-16-2012, 01:43 AM

You need some math for that. First you need to find out the field of view angle of the camera. I don't know this either, but a good estimate is just by sticking an object at the edge at a fair distance away, You then use the arctan2 function on this object. Your first parameter for the arctan function is the object distance to the left of the camera, and your second parameter is the object distance in front of the camera. What do you get? I don't know. At any rate, the result should be more or less the same as long as you keep the object more or less at the edge of the camera. Then you make a hardcoded (preset) number variable consisting of the result of the arctan function.
Congrats. you found the field of view angle.

Now you need to make sure that whenever your objects reach this edge (field of view angle), it teleports to the center of the screen.
For this, you make an if/else function. One thing you need to take note of is that you must also do the arctan thing on every object you intend on teleporting to the center of the screen. You should also save it as a number variable. So, if the arctan of the object is greater than positive FoV angle or greater than the negative FoV angle (The FoV, just with a negative sign), it does some method to move the object to the center.

This method is kind to you. You can do it simply by getting the distance to the left of the camera and having the object move that (negative) distance.
   
Reply With Quote