View Single Post
Senior Member
Dameria's Avatar
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 05-22-2010, 10:32 AM

I just made this really quickly, its an example of how you can stop something from going out of the camera field of view by pushing it forwards. This might not be exactly what you were looking for, but I don't know what you want, you would have to let me see your project for me to assess the best way to go about doing it.

All I did was put 4 cubes in the world (one for the left of the screen, one for the right, one for the front near the camera, and one as the object that is moving), and I made a simple infinite loop determining if the distance that the object is in front of each square, and if the distance is less than 0, meaning it is at the edge of the camera screen, it moves the object forwards into the field of view at a faster rate than the object itself is moving (for instance if it is moving 0.05 meters in 0 seconds, it pushes the object forward 0.1 meters so that it can not wiggle its way through the barrier). This is essentially the same thing as collision detection, but instead the walls (the half invisible black cubes) are vehicle to the camera so that they move wherever the camera goes. You can also move the camera with the mouse (move slowly to see best results) and you will see that when you move the camera so that it does not look at the cube, the cube will follow the camera and try as hard as it can to get back into the camera's view (it can only go 0.1 meters at a time though, so moving the camera too fast will make the cube go out of the view until it can catch up the the camera again).

Tell me if you need any further help or if this answered your question.
Attached Files
File Type: a2w FieldOfView.a2w (198.3 KB, 26 views)

Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ...................
Alice Paint ...........................
Real-Time Clock ..................
Maze Game .........................

Last edited by Dameria; 05-22-2010 at 10:35 AM.
Reply With Quote