My controllers aren't working

I have a controller which I'm trying to use to update a sound's position to follow a node, but despite my defining an update(float) method on a Controller subclass and using addController() on the node in question, the controller doesn't appear to be called. Not only does the sound not follow the node (the controller also starts the sound if it isn't playing, and this doesn't happen either) but the System.out.println("ping") in the update() method does not appear to output anything to the console.



So, other than adding a controller, what must be done to ensure that it runs? Is there some step other than defining the abstract update() method that is necessary to ensure that controllers are called?



Thanks.

Is the controller active? setActive(true)?

mojomonk said:

Is the controller active? setActive(true)?


Is now, but it still isn't working.

My understanding about controllers is that active/inactive status had to be checked for in the logic written into the controller? So it shouldn't matter that it may not have been active if nothing in my update() method checked activity status?

is updateGeometricState being called somewhere?

I call it once before adding the controller.



It looks like it needs to be called repeatedly, as it seems to call updateWorldData() which updates controllers (or perhaps I have the two confused. :slight_smile: Do I just need to call it once? Seems that way based on HelloIntersection, but if it calls the update() methods on the controllers then it seems like it'd need to be called repeatedly somehow.



Is there some significance to the order of things? Right now I'm calling updateGeometricState(), adding the controller then adding the node to the root node. Is that wrong? Is there some other step I'm missing?

it would be alot easier if you could post your code(relevant snip).



yes, updateGeometric state needs to be called repeatedly, but only on your topnode(usually rootNode) since that propagate all the way down to the leaf nodes…

and if you extend SimpleGame, rootNode.updateGeometricState is called automatically in it's update method.

You were right. I should've looked at the SimpleGame code more; it compltely slipped my mind that the tutorial games all descended from that.



The controller works now. Thanks for the pointer.

that's what were here for :wink:

Always glad to help  :wink: