Mounting Camera on t2dSceneObject
by N.K. · in Torque Game Builder · 08/04/2009 (3:25 am) · 3 replies
Hi,
I read the platformer tutorial and tried creating my own t2dsceneObject which the camera would track. Problem is after I mount the camera, the camera doesn't move with the object. Here's my code
//---------------------------------
$camera = new t2dSceneObject() {scenegraph = t2dScene;};
$camera.setPositionY(10); //just moving it to see if the camera will move on mounting
sceneWindow2d.mount($camera, 0, 0, 0, true); //at this point the camera moves to the new position
$camera.setPositionY(20); //at this point the camera doesn't move
//----------------------------------
By the way I've also noticed that calling setLinearVelocity(%x, %y) on $camera doesn't change its position. Any idea how I can solve these issues.
Regards,
N.K.
I read the platformer tutorial and tried creating my own t2dsceneObject which the camera would track. Problem is after I mount the camera, the camera doesn't move with the object. Here's my code
//---------------------------------
$camera = new t2dSceneObject() {scenegraph = t2dScene;};
$camera.setPositionY(10); //just moving it to see if the camera will move on mounting
sceneWindow2d.mount($camera, 0, 0, 0, true); //at this point the camera moves to the new position
$camera.setPositionY(20); //at this point the camera doesn't move
//----------------------------------
By the way I've also noticed that calling setLinearVelocity(%x, %y) on $camera doesn't change its position. Any idea how I can solve these issues.
Regards,
N.K.
About the author
#2
Could it have something to do with the fact that its a simple t2dsceneobject rather than a something rendered on screen?
08/04/2009 (9:26 am)
I do have an image in the background (the fish art background). Strangely when I mount the camera on an actual sprite, it works just fine...even with the extra parameters.Could it have something to do with the fact that its a simple t2dsceneobject rather than a something rendered on screen?
#3
08/04/2009 (12:27 pm)
i dont think so... since sprites or animations are just a "special version" of SceneObjects...
Torque Owner Ehrlich
and when i happen to move the object, the camera moves with him... i dont define the other parameters of the mount command, since most of the time i neeed the default values...
thing is, i dont really see a flaw in your code per se... but maybe you're not noticing the camera moving because of a black background or something?... please give us more info.
one last thing... next time, use the code tags ([ code ] [ / code ]) so the code you show, is more readable for us.