Game Development Community

T2dSceneObject::SetArea() console error on tutorial

by William Urban · in Torque Game Builder · 06/11/2007 (7:49 pm) · 5 replies

Hello all,

Has anyone done the tutorial/reference located here:

http://tdn.garagegames.com/wiki/Torque_2D/GenreTutorials/StrategyCameraSystem#Create_a_camera.cs

It's the Strategy Camera System and it works about 80% of the time.

What usually happens for me is sometimes when I move the mouse to the border I get a bunch of console spam saying :

t2dSceneObject::setArea() - Invalid number of parameters!
t2dSceneObject::setArea() - Invalid number of parameters!

But I can't find in the example code where this is being called. I checked in the scripts and it's not in there. Then all of a sudden the error will go away and the camera panning will work flawlessly. I looked up the SetArea method but I didn't really make heads or tail of it.

So has anyone gotten this resource to work every time correctly?

Thanks,

-Will

#1
06/12/2007 (9:02 am)
Just checked the source and it looks like "setTargetCameraPosition" will spit out that error, seems to be a mis-type... (also setTargetCameraPosition is in the script you linked to, it's been a long time since I've seen that old RTS script I did about 2 years ago :).

It seems that when you move your mouse to a certain point setTargetCameraPosition is being passed an invalid amount of arguments...

in panAction(), replace:

// lets peice our camera position together again
   $cameraPos = %x SPC %y SPC getWord($cameraPos, 2) SPC getWord($cameraPos, 3);

   // time to set and move our camera
   sceneWindow2D.setTargetCameraPosition( $cameraPos );
   sceneWindow2D.startCameraMove(0.25);

with

echo("x = " @ %x @ " y = " @ %y @ " cameraPos = " @ $cameraPos);

   // lets peice our camera position together again
   $cameraPos = %x SPC %y SPC getWord($cameraPos, 2) SPC getWord($cameraPos, 3);

   echo("cameraPos after = " @ $cameraPos);

   // time to set and move our camera
   sceneWindow2D.setTargetCameraPosition( $cameraPos );
   sceneWindow2D.startCameraMove(0.25);

and see what you get around the time you get those errors.
#2
06/12/2007 (2:13 pm)
Thanks, two years huh. Well get back to work and finish it mister! :-D Seriously though it's a great resource. I've already gotten the tile map stuff working and selecting on special tiles works and I can even select units on the tiles which is all great.

So when I changed that code here is what happens.

*EDIT* Looking back at it it looks like for the first 5-20 seconds or so the cameraPos value is a single value and when it works its a value with two numbers. That in the right direction?

x =  y = -0.25 cameraPos =  -0.25
cameraPos after =  -0.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -1.25 cameraPos =  -1.25  
cameraPos after =  -1.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -2.25 cameraPos =  -2.25  
cameraPos after =  -2.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -3.25 cameraPos =  -3.25  
cameraPos after =  -3.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -4.25 cameraPos =  -4.25  
cameraPos after =  -4.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -5.25 cameraPos =  -5.25  
cameraPos after =  -5.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -6.25 cameraPos =  -6.25  
cameraPos after =  -6.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -7.25 cameraPos =  -7.25  
cameraPos after =  -7.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -8.25 cameraPos =  -8.25  
cameraPos after =  -8.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -9.25 cameraPos =  -9.25  
cameraPos after =  -9.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -10.25 cameraPos =  -10.25  
cameraPos after =  -10.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -11.25 cameraPos =  -11.25  
cameraPos after =  -11.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -12.25 cameraPos =  -12.25  
cameraPos after =  -12.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -13.25 cameraPos =  -13.25  
cameraPos after =  -13.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -14.25 cameraPos =  -14.25  
cameraPos after =  -14.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -15.25 cameraPos =  -15.25  
cameraPos after =  -15.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -16.25 cameraPos =  -16.25  
cameraPos after =  -16.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -17.25 cameraPos =  -17.25  
cameraPos after =  -17.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -18.25 cameraPos =  -18.25  
cameraPos after =  -18.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -19.25 cameraPos =  -19.25  
cameraPos after =  -19.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -20.25 cameraPos =  -20.25  
cameraPos after =  -20.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -21.25 cameraPos =  -21.25  
cameraPos after =  -21.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -22.25 cameraPos =  -22.25  
cameraPos after =  -22.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -23.25 cameraPos =  -23.25  
cameraPos after =  -23.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -24.25 cameraPos =  -24.25  
cameraPos after =  -24.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -25.25 cameraPos =  -25.25  
cameraPos after =  -25.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -26.25 cameraPos =  -26.25  
cameraPos after =  -26.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -27.25 cameraPos =  -27.25  
cameraPos after =  -27.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -28.25 cameraPos =  -28.25  
cameraPos after =  -28.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -29.25 cameraPos =  -29.25  
cameraPos after =  -29.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -30.25 cameraPos =  -30.25  
cameraPos after =  -30.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -31.25 cameraPos =  -31.25  
cameraPos after =  -31.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -32.25 cameraPos =  -32.25  
cameraPos after =  -32.25  
t2dSceneObject::setArea() - Invalid number of parameters!
x =  y = -32.5 cameraPos =  -32.5  
cameraPos after =  -32.5  
t2dSceneObject::setArea() - Invalid number of parameters!
x = -0.5 y = -32.5 cameraPos = -0.5 -32.5  
cameraPos after = -0.5 -32.5  
x = -0.5 y = -32.75 cameraPos = -0.5 -32.75  
cameraPos after = -0.5 -32.75

So eventually it fixes whatever it is that it does to then start working. It's usually the first 5-20 seconds of being at the border. And then everything "magically works itself out" and the camera pans no problem. I don't know if it's waiting for something or what when it does this. I've tried loading levels and trying it, or stopping and starting the pan and I can't nail down why it does it.

Thanks!

-Will
#3
06/12/2007 (2:25 pm)
Ok about 1 1/2 years ago (last update I did on that listed on history is "27 January 2006 " lol). I really enjoyed doing it and glad you enjoy it. Unfortunately it ended up being a bit too in-depth and complex to be usable by most (especially at the time), though some people have picked things out of it.

It looks like cameraPos is being set to one or two numbers instead of four numbers which is where the arguments get shortchanged.

What I would do is find all the places where $cameraPos is being set and echo out the values going into it... somewhere it is being set with invalid params.
#4
06/12/2007 (3:29 pm)
Well I went back through the code and found this in the TDN :

//
//$cameraPos = getCameraPos();
$panValLeft = 1;
$panValRight = 1;
$panValUp = 1;
$panValDown = 1;

So I uncommented out the cameraPos = getCameraPos(); and that fixed all the errors right away. I wish I had seen that earlier hehe. So now there are no pauses and the panning works great! Of course now for some reason before it does that it zooms in. Must be a value I have set somewhere wierd but it zooms in and then pans around. This resource is awesome, it's got tons of helpful little tips and scripts for various strategy games. You guys ever thinking about doing more strategy/rpg resources for TGB 1.5?

Thanks again!

-Will
#5
06/12/2007 (3:35 pm)
Well I went back through the code and found this in the TDN :

//
//$cameraPos = getCameraPos();
$panValLeft = 1;
$panValRight = 1;
$panValUp = 1;
$panValDown = 1;

So I uncommented out the cameraPos = getCameraPos(); and that fixed all the errors right away. I wish I had seen that earlier hehe. So now there are no pauses and the panning works great! Of course now for some reason before it does that it zooms in. Must be a value I have set somewhere wierd but it zooms in and then pans around. This resource is awesome, it's got tons of helpful little tips and scripts for various strategy games. You guys ever thinking about doing more strategy/rpg resources for TGB 1.5?

Thanks again!

-Will