Camera Question
by David Horn · in Torque X 2D · 08/02/2009 (2:11 pm) · 3 replies
I have downloaded the Camera Manager from http://tdn.garagegames.com/wiki/TorqueX/CameraManager
I think I implemented it correctly, however the new camera does nothing...
I have a camera in my scene called "Camera" - I've tried to rename it in TXB, but it never gets saved. So I figured I'd create a new T2DSceneCamera.
Here is my code...
Can anyone see what might be wrong?
*EDIT I've actually trimmed it down to just changing the position of the camera to the player's position in the Update function and nothing happens. I can see the x and y position of the camera does change correctly, but nothing visually changes on the screen. Any ideas why that might be?
I think I implemented it correctly, however the new camera does nothing...
I have a camera in my scene called "Camera" - I've tried to rename it in TXB, but it never gets saved. So I figured I'd create a new T2DSceneCamera.
Here is my code...
public static void ringTheBell(object sender, ScheduledEventArguments scheduleEventArguments)
{
GameGUI gg = new GameGUI();
GUICanvas.Instance.SetContentControl(gg);
Game.state = "match";
// here is where I stup the camera and the manager
//*********************************************************
T2DSceneCamera WorldCam = new T2DSceneCamera();
TorqueObjectDatabase.Instance.Register(WorldCam);
WorldCam.Name = "myCam";
CameraManager.Instance.AddCamera(WorldCam);
CameraManager.Instance.Active = true;
CameraManager.Instance.MoveCameraTo2DObject("myCam", (T2DSceneObject)TorqueObjectDatabase.Instance.FindObject("camTarget"), 1, 0, 0, InterpolationMode.Linear, true, true);
CameraManager.Instance.FollowObject("myCam", (T2DSceneObject)TorqueObjectDatabase.Instance.FindObject("camTarget"), 0, false, 0, 0, InterpolationMode.Linear, true);
}Can anyone see what might be wrong?
*EDIT I've actually trimmed it down to just changing the position of the camera to the player's position in the Update function and nothing happens. I can see the x and y position of the camera does change correctly, but nothing visually changes on the screen. Any ideas why that might be?
About the author
#2
08/03/2009 (8:06 pm)
David, the only thing that I can think of from another post that I've seen before is that the camera name is not getting saved correctly in your scene file. Open it manually to check if the camera name is being saved with your name "SceneCamera". From what I remember other people had a problem with this and the builder was not saving the scene file with the name that you set...so it was only accessible if you used the default name "Camera" or if you manually set the name in the scene file.
#3
Plus, if it couldn't find the camera, I'd either get an error that it doesn't find it, and/or it wouldn't output the x property.
The other thing I did was manually create a new camera in code. but it didn't work either. Do I have to tell the level which camera to use?
08/04/2009 (6:01 am)
Yes, I've done that. It does not save it correctly as you said. So I did manually set the name.Plus, if it couldn't find the camera, I'd either get an error that it doesn't find it, and/or it wouldn't output the x property.
The other thing I did was manually create a new camera in code. but it didn't work either. Do I have to tell the level which camera to use?
Torque Owner David Horn
All I have is in my function once the level is loaded is...
T2DSceneCamera _camera; _camera = TorqueObjectDatabase.Instance.FindObject<T2DSceneCamera>("SceneCamera"); _camera.Mount(Game.wrestlers[0].pmodel, "", true);I track the camera's x coordinate using gui and it's updating fine. When the player moves, the camera moves. Except visually, nothing changes. The camera appears still.