OnPositionTarget for Camera?
by Christian Rousselle · in Torque Game Builder · 03/29/2008 (2:57 am) · 2 replies
Hi,
I am currently working on an intro where the camera needs to move to certain positions and zoom in/out at certain times. The problem I am facing is that there is no callback function like onPositionTarget for the camera. What I want to do is something like this:
The problem is that there is no callback when the movement is finished or am I missing something? I know I can mount the camera to an object an move that and have onPositionTarget but I cannot control the camera zoom this way. Does somebody have a solution?
Thank you.
I am currently working on an intro where the camera needs to move to certain positions and zoom in/out at certain times. The problem I am facing is that there is no callback function like onPositionTarget for the camera. What I want to do is something like this:
sceneWindowPlayer0.setCurrentCameraPosition(0, 0); sceneWindowPlayer0.setTargetCameraZoom(2); sceneWindowPlayer0.setTargetCameraPosition(120, 80); sceneWindowPlayer0.startCameraMove(5); // and after that movement is finished I want to do the next movement sceneWindowPlayer0.setTargetCameraZoom(4); sceneWindowPlayer0.setTargetCameraPosition(320, 180); sceneWindowPlayer0.startCameraMove(5);
The problem is that there is no callback when the movement is finished or am I missing something? I know I can mount the camera to an object an move that and have onPositionTarget but I cannot control the camera zoom this way. Does somebody have a solution?
Thank you.
#2
t2dSceneWindow.cc, Lines 832-848
Handling the callback in TorqueScript seems to work very good - at least so far. Maybe somebody from GG or some of the more expericenced TGB developers can comment on this?
Thanks
03/29/2008 (9:04 am)
Diego, thank you for your answer. I thought about the scheduling solutions already but to be honest in my opinion this callback is missing. Polling getIsCameraMoving() in whatever function is not nice imho. I modified the source (1.7.2):t2dSceneWindow.cc, Lines 832-848
// Complete Camera Move.
void t2dSceneWindow::completeCameraMove( void )
{
// Quit if we're not moving.
if ( !mMovingCamera ) return;
// Reset Tick Camera Time.
resetTickCameraTime();
// Move straight to target.
mCameraCurrent = mCameraTarget;
// Reset Camera Move.
mMovingCamera = false;
// callback - camera finished movement
Con::executef( this, 1, "onCameraMoveComplete" );
}Handling the callback in TorqueScript seems to work very good - at least so far. Maybe somebody from GG or some of the more expericenced TGB developers can comment on this?
Thanks
Torque Owner Diego Santos Leao - GameBlox Studio
If you need precision, you can also inspect the camera position using the "onUpdate" callback. When the camera reaches a predefined position, you call the method containing the next tasks.
I was having problems just like yours, and I figured I needed to start thinking in terms of callbacks and scheduling instead of "how to know when the previous task is done". There is almost always a way to do what you want!
Don't be afraid to ask again about the same subject though ;) I did and it helped me a lot.
Good luck!