- Home /
Slow motion everything but player.
Hello.
I want to "slow motion time" on every object in the scene including physics and scripts, but also want my player character (rigidbody) continues normal movement. I've used things like sending pause messages: Player script:
if (Input.GetMouseButton(1)){
var objects : Object[] = FindObjectsOfType(GameObject);
for (var pause : GameObject in objects) {
pause.SendMessage ("ScriptPaused", SendMessageOptions.DontRequireReceiver);
}
}
}
Another object script:
private var paused : boolean;
function ScriptPaused(){
paused = true;
}
function Update (){
if (!paused) {
// script
}
}
Also setting objects kinematic to true and pausing mecanim animations. It works fine in pause, but I want to know if it's possible use Time.timeScale to slow motion specific objects or create my own deltaTimes and how's Fixed and LateUpdate affected.
Thanks.
Answer by fafase · Sep 13, 2013 at 08:12 PM
I would guess you have everyone moving using Time.deltaTime. I fyou modify Time.timeScale you can modify the speed of execution, with 0 < timeScale < 1 you slow down all movement and animations since they are based on deltaTime which gets affected.
But your player will also slow down so you need to get him back to one.
you can easily put this one at the top of your player script, so that your player moves normal speed:
if(slowDown){
timeScale = 1;
}
and then at the end you set it back for other scripts
if(slowDown){
timeScale = slowSpeed
}
this way no big computation required and this will work as long as you do not have multi threading (I doubt you have anyway).
Thanks for your answer, but everything goes slow yet. I've tried different values and nothing, player keep going in slow speed (Animations, transform, physics):
function Update(){
if(slowDown) Time.timeScale = 1.0;
if (Input.Get$$anonymous$$ouseButtonDown(1)){
slowDown = !slowDown;
}
if(slowDown) Time.timeScale = 0.3;
//All Script....
}
I'm also using FixedUpdate in player script to move/rotate rigidbody.
I guess you also need a speed and a fastSpeed to multiply the velocity.
Your answer
Follow this Question
Related Questions
Play button & pause button activates at the same time, can not play the created scene 0 Answers
Play button & pause button activates at the same time, can not test the scene 1 Answer
Drop-down enum pauses player - must it be so? 1 Answer
Can someone help me with my player kill script? 0 Answers
Pause Menu Text Not Rendering 0 Answers