Game Development Community

Beta onUpdateScene not being called

by Shane · in Torque Game Builder · 02/11/2006 (1:41 am) · 5 replies

I figured out (i think) why my level wont scroll around. For some reason it seems that my onUpdateScene function is not being called:

function t2dSceneGraph::onUpdateScene(%this)
{
	echo("IN UPDATE SCENE!");
   if (%this != t2dscene.getID())
      return;


   for(%i = 0; %i < EnemyGroup.getCount(); %i++)
	{
		updateEnemy(EnemyGroup.getObject(%i));
	}	
   updatePlayer();
	echo("ABOUT TO UPDATE SCENE!");
   $camera.update();
   $runSurface = -1;
}

I don't see any of the echos, and none of the functions here are being executed. So what am I doing wrong? All I really did was copy the stuff over from alpha 1.something to the newest beta and this stopped working. Any ideas? Is the function deprecated? do i have to invoke someting else ? or do I just have the above chunk of code in the wrong .cs file.

Thanks.

-Shane

#1
02/11/2006 (2:19 pm)
Hmmm no one else running into this? It is probably some stupid mistake I did, and I will feel completely ignorant when I finally figure it out.
#2
02/11/2006 (2:44 pm)
Hi,

are you sure, you exec() the .cs file this is in? Or maybe t2dSceneGraph::onUpdateScene is defined a second time somewhere else?
Deleting the .dso file in question may help too. Check your console.log for script compilation errors.

Maybe one of the things helps :)
Good luck!
#3
02/11/2006 (3:12 pm)
Read the rest but first i just saw:
function t2dScene::onUpdateScene(%this)
{
	echo("MOUSE UPDATE SCENE!!");
        if(($mouseObj::follow) && (!$mouseObj::stopped))
                mouseObjCheck();        
}
in my moveMouse.cs , so I cannot have two call backs at the same time?
So it is defined in two places... I guess this is illegal? I took it out and it does seem towork now, so I have no clue why I was doing the onUpdateScene stuff in the moveMouse, if I still needed those checks and the call to mouseObjCheck();, i could just do it in the onUpdateScene thast called elsewhere right? torque script has noc oncept of what the calling file was (i.e. the mouse checks doesnt have to be in the moveMouse.cs it can be in the game.cs or whereever i decide to stick my onUpdateScene?)
#4
02/11/2006 (6:41 pm)
Generally, people that implement callbacks only support a single callback function to be defined and active at any point in time. There are a bunch of complicated issues that arrise if you want to support multiple delegates on the same callback: what order do you call them in? What happens if one of the delegates wants to cancel? Do you call the others? How do you ensure there aren't side effects from each delegate that cause unpredictable behavior?

So, to answer your question, yes it is illegal in Torque Script to have multiple handlers (or delegates) for a single callback... and for good reasons.
#5
02/11/2006 (7:25 pm)
Quote:So, to answer your question, yes it is illegal in Torque Script to have multiple handlers (or delegates) for a single callback... and for good reasons.

Well, I wouldn't go so far as to say "good reasons." As with everything else, it is a question of the specific details.

For an animation callback, the issues you state seem quite reasonable. However, for a generic, onSceneUpdate callback, it's not unreasonable for the user to want to do lots of different things on every scene update. Also, the likelihood of callback interference (one callback needing the results of another) is pretty minimal. And should this be the case, it's on the user to resolve this.

In the general case, I would suggest that one should be able to have multiple active onSceneUpdate callbacks, each one being independent on the others.

Granted, the mechanism in which the callback is implemented (ie, as an override function rather than an explicit registration of a callback) doesn't allow for this. And that is unfortunate.