Slow down time or Bend time like in the game dishonored

I know you can use the time.timescale to an extent but i’m sure thats not all maybe speed up animations. Whats the best approach to get a slow motion effect like in the game dishonored when you activate the ability to bend time if you have played it

You can use Time.timeScale, but for things that will move normally even if time is slow down, you will need to include a different variable for them for their time-based movement.

public class TimeFabric {
   private static float timeScale;

   public static void SetTimeScale( float ts ) {
      Time.timeScale = ts;
      timeScale = ts;
   }

   public static float DeltaTime( bool affectBySlowTime ) {
      return Time.deltaTime / (affectBySlowTime)? 1f : timeScale;
   }

   public static float DeltaTime() {
      return Time.deltaTime;
   }
}

So, you will use TimeFabric to control the timeScale. TimeFabric.DeltaTime() is used as replacement for all gameObject that depends on Time.deltaTime.

For example, you have 2 script, one for player movement, another for an arrow. When you move your player forward by pressing W, you will use something like this:

player.position.Translate(Vector3.forward *speed *TimeFabric.DeltaTime( false ));

When the arrow is shot, and it start moving, it will do something like this:

arrow.position.Translate(Vector3.forward *speed * TimeFabric.DeltaTime() );

What happen now is that your player will move normally even if the time is slow down, but the arrows will be affected by the time.

Please take note that this will not work properly with TimeFabric.timeScale = 0, if you want to stop time completely, you will need to write a more complex class; I also did not take in consideration on reversing the flow of time here, it is very complex, and a simple script will not be able to pull it off.

See Time.timeScale , it shows an example of this

How about this:

static var bendTime : boolean;
function Update(){
if(bendTime == true){
Time.timeScale = 0.8;
yield WaitForSeconds(0.6);
Time.timeScale = 0.6;
yield WaitForSeconds(0.4);
Time.timeScale = 0.4;
yield WaitForSeconds(0.2);
Time.timeScale = 0.3;
yield WaitForSeconds(0.2);
Time.timeScale = 0.6;
yield WaitForSeconds(0.5);
Time.timeScale = 0.8;
yield WaitForSeconds(0.5);
Time.timeScale = 1;
}
}

Then somewhere else have something triggering the boolean
as it’s a global variable .
Hope it helped :smiley:
Johnny