Render Spatial only when needed

I have a question, is it possible to render spatial when i need it
for example:

if (a > 3) {
render(spatial);
}

so only if a > 3 spatial renders, otherwise you can’t see it.

Attaching and detaching makes game lag.

You can set the cull hint to always to make it disappear.

http://javadoc.jmonkeyengine.org/com/jme3/scene/Spatial.html#setCullHint(com.jme3.scene.Spatial.CullHint)

1 Like

Thanks, it worked