Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

10 years ago by Rungo73

Want to slow down game time for everything but my player entity.

I cam across this plugin:

http://impactjs.com/forums/code/time-slowdown-plugin/page/1

Which works great - just dont know how to isolate the player so that its not affected by the slowdown.

@SlouchCouch can you help?

10 years ago by Krisjet

Hmm, modifying the timeScale (like this plugin does) won't help you much, since that affects all the entities in the game. I don't see an easy way to do this actually, although maybe you could try frame skipping updates on the entities you want to have in slow motion?

I suggest trying out something like this on the entities you want to only update every other frame, just to see what kind of bugs you'll get.

In the update() of the entities you want to have half speed:
if(this.updateFrame){
    this.parent();
    this.updateFrame = false;
} else {
    this.currentAnim.update();
    this.updateFrame = true;
}

Just tried it in one of my projects and at first glance it works. I anticipate some collision bugs though, as you'll essentially be skipping collision detection every other frame.

10 years ago by DanielGray

I have an ugly solution that should work.

Use a global variable that modifies the velocity, gravity, etc of all other entities aside from the player. Then multiply that variable by the things that slowing down time would affect.

Example:
timeScale = 1; //Default time

if( timeSlow ){
    timeScale = 0.5;
}

In some entity

this.currentvel.x *= timescale; //this would cause the entity to appear to be traveling at half its current rate during timescale effects.

Obviously you'd need to alter animation rates as well, and reduce them by the rate at which you want to slow down time.

10 years ago by drhayes

What about setting the global time scale and then compensating on the player? i.e., slow down the game but speed up the player's velocity and animation rate? Does that work?
Page 1 of 1
« first « previous next › last »