Question - How do you change the UserTime in the middle of a game

RusRus
edited February 2016 in Help
I want to change the pace of the animation during the middle of a animation.

I've been fiddling around with the setUserTimeMSec and updateUserTimeMSec functions.
I had no problems with setting the pace of the animation once. But when I need to set it during the middle of a animation, then the animation breaks, ie the Live2d character disappears off the screen.

So my question is: Can you actually change the pace of the animation during the middle of a animation? If yes, how do you do it properly?

This is what I am doing.

var multiplier = 1;

PERIODIC UPDATE FUNCTION:
if(condition){multiplier = 2;}
UtSystem.setUserTimeMSec( UtSystem.updateUserTimeMSec() * multiplier );

Comments

  • If you can't understand my question, I will explain my problem like this:

    Something like this works fine:
    
    PERIODIC UPDATE FUNCTION:
    UtSystem.setUserTimeMSec( UtSystem.updateUserTimeMSec() * 2); // ie: a constant, and the animation goes twice as fast.
    
    But something like this don't work:
    
    PERIODIC UPDATE FUNCTION:
    UtSystem.setUserTimeMSec( UtSystem.updateUserTimeMSec() * Math.random() ); 
    
  • I am stuck with this trouble. Can someone please help me? Thank you in advance )
  • The purpose I ask this is that I want to make an animation that moves faster and faster. (if this makes my question more understand-able)
  • edited December 2015
    I have tried in Unity.
    Motion speed for each model has been changed .

    left model(speed:1), right model(speed:5)


    However , this function can't be changed dynamically .
    I will try to the request to the development team to be additional functions .
  • Thank you. I wish I could dynamically slow-down and speed-up animations.

    After some trying, I managed to do this (speeding up animation dynamically) :
    
    var Simple = function() {
            ...
    	ha.addEventListener("mousedown", function(){
                    speed_up_flag1 = false; 
                    speed_up_flag = true;
            });
    	ha.addEventListener("mouseup", function(){
                    speed_up_flag1 = true; 
                    speed_up_flag = false;
            });
            ...
    };
    
    
    Simple.draw = function(gl){
            ...
    	if(speed_up_flag){
    		UtSystem.setUserTimeMSec( UtSystem.updateUserTimeMSec()*2 );
    	}
    	if(speed_up_flag1){
    		UtSystem.setUserTimeMSec( UtSystem.updateUserTimeMSec()*3 );	
    	}
    	
            live2DModel.update(); 
            live2DModel.draw();	
    }
    
    HOWEVER, I can't slow down the animation, for example, like this (i.e. setting it to a faster pace, and then setting it to a slower pace) :
    
    	if(speed_up_flag){
    		UtSystem.setUserTimeMSec( UtSystem.updateUserTimeMSec()*3 );
    	}
    	if(speed_up_flag1){
    		UtSystem.setUserTimeMSec( UtSystem.updateUserTimeMSec()*2 );	
    	}
    
    If I can dynamically speed up the animation, why can't I dynamically slow it down?
  • I was also able to change the speed by increasing the value .
     1. UtSystem.updateUserTimeMSec() * 2 → OK
     2. UtSystem.updateUserTimeMSec() * 4 → OK
     3. UtSystem.updateUserTimeMSec() * 6 → OK

    However , the reverse is impossible .
     1. UtSystem.updateUserTimeMSec() * 6 → OK
     2. UtSystem.updateUserTimeMSec() * 4 → NG
     3. UtSystem.updateUserTimeMSec() * 2 → NG

    When you debug the value of updateUserTimeMSec(), time increases .


    It can't possibly return the time .
    I think that it is not a dynamically changing function of the speed .
  • Ok. Thank you
Sign In or Register to comment.