Animation pause when game paused


I just discovered there was no real way to pause an animation, (or maybe set its speed to 0)

but as I want to pause the whole game(via custom appstates), the only solution would be to
create a list of animchannel and their respective speed on pause,and restoring each of them on resume…
is there no other way ?

there should be a global anim enable/disable feature ?


hrmm… depends on if you have your animation data centered on the graphical update side of things or the game logic update side of things.

and there is a setGamePaused(true) type feature in jMonkeyEngine… it skips the game logic side of things if i remember correctly. (My head is full of netbeans atm, srry.)

so you would probably want to set up a method to skip the geometric update side of things for your animated meshes (they can check in with that isGamePaused thingy, and skip the geometric update too! :smile: ), or move the control of the animations to the game logic side.

Either way, you will be +1 level for your skills in jME, though the first of the two options should be easier to implement.

Game On,

Can you not set the speed to 0?

Short of that save the frame and continuously set it to that frame on the update loop.

I don’t see why not. It should work out just fine with that solution, as well. I’m just too rusty in the class specifics to be of any help on code, atm.

what if you have a game with “thousands” of animations ?

I guess I’ll have to create a hashmap<control, float> to restore each AnimChanel speed value

I’ll try to override the AnimChanel adding a Pause() function

it’s the overall anim system I want to stop
besides, I did not find any setGamePaused, the doc also says appstates should be used to deal with game states
(and even with gamestates I cant stop the updating of the overall anim system)

here in AnimControl code:

    protected void controlUpdate(float tpf) {
        if (skeleton != null) {
            skeleton.reset(); // reset skeleton to bind pose

        TempVars vars = TempVars.get();
        for (int i = 0; i < channels.size(); i++) {
            channels.get(i).update(tpf, vars);

        if (skeleton != null) {

is there a way to stop all control updates ?? cos they are updated automaticaly
as long as they are attached to a spatial

Anims works with tfp. so pausing the game should stop the anims.

However, when you unpause the game, you have a “jump” in anims because the tpf given after a long pause is the duration of the pause.

What I usually do to alleviate this is that I have my own Timer Class that I give JME (in your simpleInit just cal setTimer(YourTimer).
This timer is the same as NanoTimer, except it “erase” any tpf values that are greater then 0.2 with 0.016.
This way if you pause during 10 minutes you’ll only have a normal frame advance as you would at 60 fps when resuming.

problem is that the game is paused while waiting for a key to be pressed
and jumps in anims are ok for me I dont care
I just want to pause the anim system, I don’t know how

here in

public void update(float tpf) {
        if (!enabled)


so I need to stop jme from updating controls

Did you try app.setPaused(true)?
It pauses everything.

Or do you want something else. not sure I get what you are looking for

??? I cant find any setPaused in the app variable

mhh thought we had an accessor for this.
anyway from the SimpleApplication you can call

paused = true;

works a bit too well, it wont take any input request after that :smile: so I cant unpause the game anymore

I want to pause things when in dialog with an npc or in inventory mode

worst case I’ll only put the player on pause, leaving the other animations, but what if there are enemies around ??
with my appstates I can stop the AI, but enemies would stay where they are, doing the last anim they were assigned…crappy

so a handy way to stop all spatials updates would be neat in JME

Every object with bones have its own AnimControl (or something like that). Create your own MyAnimControl, override controlUpdate this way:

protected void controlUpdate(float tpf)
   if (MyGlobalTimer.getInstance().isPaused()) return;


Replace AnimControl with your class ewerywhere.

well AnimControl is a final class, cant override it
damned !!
guess I’ll have to fork AnimControl like I did for the weak particle system classes
I hate to do that

Yeah… I went on ahead and looked up the value that I was vaguely recalling in the other post…

look at
I think this was what I was remembering…

Anyways, extends, and the typical test game follows something like…
public class Main extends SimpleApplication {

public static void main(String[] args) {
    Main app = new Main();
    AppSettings appSettings = new AppSettings(true);
    appSettings.setResolution(800, 600);
    appSettings.setTitle("Iteag Toolkit");
} ... more code till end

you could just alter it like so:

public class Main extends SimpleApplication {
    private Main app; //now we can check app.paused anywhere... 
    // try "app.paused = true;" in one of the methods as one way to check...

    public static void main(String[] args) {
        app = new Main();
        AppSettings appSettings = new AppSettings(true);
        appSettings.setResolution(800, 600);
        appSettings.setTitle("Iteag Toolkit");
    } ... more code till end

oh duh I didn’t think about that.

Well another solution that IMO is the cleanest, is to have an AppState that handles the update of your scene.
Give up on SimpleApp rootNode, and have an AppState that has its own rootNode. Put your scene in in the AppState’s root node and in the update of the AppState go :

if (!paused){

This way you can just pause the AppState and have everything freezing in the scene but still keep inputs and everything else.

I used this in one of my game to stop the render when the option menu was up on android. it works pretty fine.

I dont follow you
as said above
paused=true freezes everything, even input manager

yes that sounds great actually
I’ll try this

Also, note that you can extend AbstractAppState directly and have a built in enable/disable management, so you just have to disable the AppState to pause your scene update actually

totaly :smile: