Game Development Community

Parallax Behavior: keeping inside Camera View limits

by Kevin Epps · in Torque Game Builder · 03/11/2008 (7:30 pm) · 2 replies

Is there a way to edit this to stop a a parallax behavior once you reached a camera view limit?

I added values to set a camera view limit to the Mounting Behavior, so I'm wondering if that could be done as well?

#1
03/11/2008 (8:43 pm)
It is difficult and rather stupid, but it is possible.

At the moment, there is no method of recalling the view limits on a camera, so, when you set the view limit, you're going to need to store those values somewhere. Next, when the parallax scroll rate is updated you will need to check if the min and max values of the camera lie outside of those values, if they are, set the scroll rate to zero.

Here is a quick and dirty script I just made up:

%myViewLimit = "-100 -100 100 100";
%cameraArea = sceneWindow2d.getCurrentCameraArea();
 
// Check X-Axis
if (getWord(%cameraArea, 0) < getWord(%myViewLimit , 0) || getWord(%cameraArea, 2) > getWord(%myViewLimit , 2))
   %scrollSpeedX = 0;
 
// Check Y-Axis
if (getWord(%cameraArea, 1) < getWord(%myViewLimit , 1) || getWord(%cameraArea, 3) > getWord(%myViewLimit , 3))
   %scrollSpeedY = 0;
#2
03/12/2008 (1:03 pm)
Thanks!!! Worked like a charm!!