Dynamic objects and code


Don’t you use Scene composer ?


The sdk should be your first choice since you are learning. After I updated it to java 1.8.192 it works real well.

SceneComposer will allow you to experiment with what you learn from reading the wiki without knowing how to code but also allows you to do the same things procedural so you can learn.

It also comes configured with assets folders and compiling ready to go as well as having access to code templates for easily generating controls, appstates, materials, material definitions, and much more.


I created my own CustomControl, so they don’t run in SceneComposer, you just need to go through all your scene nodes and enable those that have a CustomControl on game init.

public class AbstractControlInit  extends AbstractControl{
    public boolean enableControl = false;
    protected void controlUpdate(float tps){
        if (enableControl) {
    protected void controlRender(RenderManager rn, ViewPort vp){                
    protected void updateDelta(float tps){

Would it be more logical the SDK have CustomControls not enabled by default ?
This would avoid us all that stuff.

Why CustomControl have ControlUpdate() but no ControlInitialization() method ?


You’re complicating it quite a bit. Don’t try to avoid learning the basics first.
AbstractControl already has an enabled flag which you don’t have to check manually inside update() because the engine does that.

You can override AbstractControl’s setSpatial() method to do initialization/cleanup:

public void setSpatial(Spatial spatial) {
    if(spatial != null) {
        // Initialization
    } else {
        // Cleanup

But IMO that’s rarely necessary because Controls are not often reused.

I do something like this to enable the Controls:

    Spatial model = assetManager.loadModel("Models/model.j3o");
    model.depthFirstTraversal((Spatial spatial) -> {
        for(int i=0; i<spatial.getNumControls(); ++i)


And if I’m not mistaken: When you extend AbstractControl instead of implementing Control you can even right click and start/stop all controls or individual controls with exactly that mechanism.
If the default should be true or false, that’s a thing to argue about with valid arguments for both sides. It could be that this enabled state is serialized as well, in which case one could argue again if this is wanted or not.