Game Development Community

OnUpdate() and onUpdateScene() are not being called. Why?

by Hamish Fawns · in Torque Game Builder · 07/19/2008 (8:30 am) · 6 replies

In my game the function MyLevelSceneGraph::onUpdateScene() never gets called nor do any of the Myt2dSceneObject::onUpdate() functions. What might cause this? The Myt2dSceneObject::onLevelLoaded() functions are being called so the objects are registered.
I tried to see what I'm doing differently from the AStarDemo which does have all its onUpdate functions by comparing all the files but couldn't see any relevant differences.

Do I need to set some options somewhere to get the onUpdate() and onSceneUpdate() functions to be called?

I am calling Myt2dSceneObject::enableUpdateCallback() in the objects onLevelLoaded function.

Thanks. It's driving me crazy

#1
07/19/2008 (9:19 am)
When you say you defined the method "MyLevelSceneGraph::onUpdateScene()", did you actually name your sceneGraph? It doesn't have a name by default so you would want to make your callback in the t2dSceneGraph namespace. Eg.

function t2dSceneGraph::onUpdateScene( %this )
{
}
#2
07/19/2008 (2:35 pm)
Oh, I think I figured it out. The update functions were empty. Unlike Visual C++ they need to contain some code to actually be called so I had a breakpoint in there that was not being hit. As soon as I added a line echo("onUpdate called"); the breakpoint was hit and the callbacks were called.

I wonder if this is a bug or a design choice? I'd prefer it if they were always called even when empty because when I'm testing I like to see whether my functions are called before I start writing code. That's just me and not a big deal at all.

Thanks!
#3
05/07/2011 (7:43 am)
I really not understand how to change something using the onUpdateScene. It seem never called by anything, is a week i try to make a small thing work like i want and nothing seem to do what i expect.

I'm using iTorque2D and the documentation seem very poor for that, i see the camera set and other things refer to the Torque2D so i suppose to use that but only some events seem to work.

i need to move the camera with an object but when i check the onUpdate or the onUpdateScene nothing change the program seem to not going inside.

I supposed was a problem of the enableupdatecallback but if i use it i get error from the torsion.

What i have to do ?
#4
05/07/2011 (8:33 am)
@7 Raven What particular error are you having ?

Are you trying to update the camera with the object? Have you try mounting the camera with the object instead?
#5
05/07/2011 (9:52 am)
If i mount the camera to an object work but how i can move the camera connected to some position of that object ? The camera i need follow that object not always.

Why i can't use the function sceneWindow2D::onUpdateScene(%this) ??

Why the function is never called ?

#6
05/07/2011 (5:20 pm)
You can mount the camera to an object with a specific offset. If you are working on the iPhone, I don't really recommend using the "onUpdate" callback.

What is the error iTGB is throwing? I haven't used the latest iTGB so I'm not sure if GG added a flag to recompile the engine to enable "onUpdate" callback or something. You might need to check the source on that.