Advanced Camera implementation problem
by Robert S. · in Torque Game Engine · 11/01/2005 (1:20 pm) · 9 replies
Hi,
I am working on a RTS style game where I have several avatars, each of them implemented as AIPlayers. By default the camera is set in toggleCameraFly mode. I tried to add the Advanced Camera (see http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471) to the application because I want to add third person mode for avatars. I want that each avatar can be "followed" by the camera.
My first problem was how to get the pointer of the GameConnection object because I am not using the GameConnection::createPlayer() Finally I decided to create a global variable which will get the value of %this in GameConnection::createPlayer() and use it for assigning the advanced camera object with an avatar.
I tried the above implementation but it isn't working. When I call the below lines:
$gGameConnection.advCamera.setPlayerObject(%avatar);
$gGameConnection.advCamera.setThirdPersonMode();
$gGameConnection.advCamera.setFollowTerrainMode(false);
$gGameConnection.advCamera.setVerticalFreedomMode(false);
$gGameConnection.setCameraObject($gGameConnection.advCamera);
it does nothing. The camera remains in the old position, which is the old camera object in toggleCameraFly mode. I checked with the debugger and the $gGameConnection, $gGameConnection.advCamera and %avatar are valid objects and also the AdvancedCamera::advanceTime() is called periodically.
Any idea what the problem can be? I am wondering if I should switch the camera from the old camera to the new Advanced Camera? Is there anybody who has experienced the same problem?
Any suggestion is welcome.
Thanks.
I am working on a RTS style game where I have several avatars, each of them implemented as AIPlayers. By default the camera is set in toggleCameraFly mode. I tried to add the Advanced Camera (see http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471) to the application because I want to add third person mode for avatars. I want that each avatar can be "followed" by the camera.
My first problem was how to get the pointer of the GameConnection object because I am not using the GameConnection::createPlayer() Finally I decided to create a global variable which will get the value of %this in GameConnection::createPlayer() and use it for assigning the advanced camera object with an avatar.
I tried the above implementation but it isn't working. When I call the below lines:
$gGameConnection.advCamera.setPlayerObject(%avatar);
$gGameConnection.advCamera.setThirdPersonMode();
$gGameConnection.advCamera.setFollowTerrainMode(false);
$gGameConnection.advCamera.setVerticalFreedomMode(false);
$gGameConnection.setCameraObject($gGameConnection.advCamera);
it does nothing. The camera remains in the old position, which is the old camera object in toggleCameraFly mode. I checked with the debugger and the $gGameConnection, $gGameConnection.advCamera and %avatar are valid objects and also the AdvancedCamera::advanceTime() is called periodically.
Any idea what the problem can be? I am wondering if I should switch the camera from the old camera to the new Advanced Camera? Is there anybody who has experienced the same problem?
Any suggestion is welcome.
Thanks.
About the author
Creator of VisitorVille.com
#2
11/02/2005 (10:56 am)
Thanks for your reply. I don't know how to switch the camera mode. I tried to call the ToggleCamera (alt - c) but that does nothing. Do you have any idea how to do it?
#4
However, now I am experiencing another problem. When I switch to first person mode, at first your camera isn't behind the player but far away, and it takes some time to move to it. Before switching to first person mode I tried to move the camera to the position of the avatar, but unfortunately the same thing occurs. I tried to move the camera with setPosition() and setCameraPosition(). Is there another method I should try? Do you know how this can be remedied?
11/06/2005 (9:20 am)
Thank you.However, now I am experiencing another problem. When I switch to first person mode, at first your camera isn't behind the player but far away, and it takes some time to move to it. Before switching to first person mode I tried to move the camera to the position of the avatar, but unfortunately the same thing occurs. I tried to move the camera with setPosition() and setCameraPosition(). Is there another method I should try? Do you know how this can be remedied?
#5
Either turn of the interpolation - thats what I did, or create some console method that sets the position without using interpolation
11/06/2005 (2:25 pm)
Yeah - the problem is the interpolation code used + first time you activate the camera it is placed at 0,0,0 (check the constructor for the class - thats where its set). Thus for the first few frames the camera will speed from 0,0,0 to the position where its supposed to be.Either turn of the interpolation - thats what I did, or create some console method that sets the position without using interpolation
#6
11/09/2005 (9:58 am)
Thank you very much for your answer. It really helped me.
#7
How do I turn off the camera interpolation?
Luck!
Guimo
08/09/2006 (2:39 pm)
I have just that problem. The camera if flying from the startup point to the position above my character. How do I turn off the camera interpolation?
Luck!
Guimo
#8
i get this when i try to zoom in the console
keyboard0 input device unacquired.
DirectInput deactivated.
keyboard0 input device created.
mouse0 input device created.
Activating DirectInput...
keyboard0 input device acquired.
all my binds are exactly like the tutorial says to do
moveMap.bind(mouse0, "xaxis", rotateCameraHorizontal);
moveMap.bind(mouse0, "yaxis", rotateCameraVertical);
moveMap.bind(mouse0, "zaxis", zoomCamera);
anyone have any ideas?
and btw, for those of you who want to use the orbit mode, there is a tutorial that lets you walk left and right with the default orc and animations, see here
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5934
08/10/2006 (9:21 pm)
Im having problems with the zoom effect on the orbit mode of this camera system. it wont zoom at all, i get this when i try to zoom in the console
keyboard0 input device unacquired.
DirectInput deactivated.
keyboard0 input device created.
mouse0 input device created.
Activating DirectInput...
keyboard0 input device acquired.
all my binds are exactly like the tutorial says to do
moveMap.bind(mouse0, "xaxis", rotateCameraHorizontal);
moveMap.bind(mouse0, "yaxis", rotateCameraVertical);
moveMap.bind(mouse0, "zaxis", zoomCamera);
anyone have any ideas?
and btw, for those of you who want to use the orbit mode, there is a tutorial that lets you walk left and right with the default orc and animations, see here
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5934
#9
04/26/2007 (5:25 am)
I have the same Grant's problem. I can't control the camera with mouse in orbit mode and I don't know why...
Torque Owner Thomas \"Man of Ice\" Lund