Slow down time Unity3d Mecanim
up vote
0
down vote
favorite
I am trying to slow down and ultimately stop it, i have a script that slows down timeScale however with that my player using mecanim also slows down.
I have created a TimeController.cs
that will allow me to keep track of time by having a alternative deltaTime as the player can use for variable,
public class TimeController : MonoBehaviour {
private float oldTimeSinceStart;
public float deltaTime;
void LateUpdate () {
float timeSinceStart = Time.realtimeSinceStartup;
deltaTime = timeSinceStart - oldTimeSinceStart;
oldTimeSinceStart = timeSinceStart;
if (Input.GetButton("BulletTime"))
{
if (Time.timeScale > 0.01)
{
Time.timeScale -= 0.004f;
}
}
else
{
if (Time.timeScale < 1)
{
Time.timeScale += 0.01f;
}
}
}
}
From this point i thought about using Animator Update to set the mecanim logic driven speed for player speed and animation speed, however i dont seem to be able,
When using Animator.Update(MyTimeController.deltaTime);
It seems to run at variable speed, as if the Animator has a second input somewhere.
is there away around this? can you isolate the timeScale from the player/mecanim and have it look at another Time class for input variables?
So time slows down for the world but not the player, think clockstoppers!
c# time unity3d
add a comment |
up vote
0
down vote
favorite
I am trying to slow down and ultimately stop it, i have a script that slows down timeScale however with that my player using mecanim also slows down.
I have created a TimeController.cs
that will allow me to keep track of time by having a alternative deltaTime as the player can use for variable,
public class TimeController : MonoBehaviour {
private float oldTimeSinceStart;
public float deltaTime;
void LateUpdate () {
float timeSinceStart = Time.realtimeSinceStartup;
deltaTime = timeSinceStart - oldTimeSinceStart;
oldTimeSinceStart = timeSinceStart;
if (Input.GetButton("BulletTime"))
{
if (Time.timeScale > 0.01)
{
Time.timeScale -= 0.004f;
}
}
else
{
if (Time.timeScale < 1)
{
Time.timeScale += 0.01f;
}
}
}
}
From this point i thought about using Animator Update to set the mecanim logic driven speed for player speed and animation speed, however i dont seem to be able,
When using Animator.Update(MyTimeController.deltaTime);
It seems to run at variable speed, as if the Animator has a second input somewhere.
is there away around this? can you isolate the timeScale from the player/mecanim and have it look at another Time class for input variables?
So time slows down for the world but not the player, think clockstoppers!
c# time unity3d
@Bart, following my example? :-p
– Steven
Mar 22 '14 at 19:58
1
Ha @Steven, isn't the first, won't be the last. ;)
– Bart
Mar 22 '14 at 20:06
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to slow down and ultimately stop it, i have a script that slows down timeScale however with that my player using mecanim also slows down.
I have created a TimeController.cs
that will allow me to keep track of time by having a alternative deltaTime as the player can use for variable,
public class TimeController : MonoBehaviour {
private float oldTimeSinceStart;
public float deltaTime;
void LateUpdate () {
float timeSinceStart = Time.realtimeSinceStartup;
deltaTime = timeSinceStart - oldTimeSinceStart;
oldTimeSinceStart = timeSinceStart;
if (Input.GetButton("BulletTime"))
{
if (Time.timeScale > 0.01)
{
Time.timeScale -= 0.004f;
}
}
else
{
if (Time.timeScale < 1)
{
Time.timeScale += 0.01f;
}
}
}
}
From this point i thought about using Animator Update to set the mecanim logic driven speed for player speed and animation speed, however i dont seem to be able,
When using Animator.Update(MyTimeController.deltaTime);
It seems to run at variable speed, as if the Animator has a second input somewhere.
is there away around this? can you isolate the timeScale from the player/mecanim and have it look at another Time class for input variables?
So time slows down for the world but not the player, think clockstoppers!
c# time unity3d
I am trying to slow down and ultimately stop it, i have a script that slows down timeScale however with that my player using mecanim also slows down.
I have created a TimeController.cs
that will allow me to keep track of time by having a alternative deltaTime as the player can use for variable,
public class TimeController : MonoBehaviour {
private float oldTimeSinceStart;
public float deltaTime;
void LateUpdate () {
float timeSinceStart = Time.realtimeSinceStartup;
deltaTime = timeSinceStart - oldTimeSinceStart;
oldTimeSinceStart = timeSinceStart;
if (Input.GetButton("BulletTime"))
{
if (Time.timeScale > 0.01)
{
Time.timeScale -= 0.004f;
}
}
else
{
if (Time.timeScale < 1)
{
Time.timeScale += 0.01f;
}
}
}
}
From this point i thought about using Animator Update to set the mecanim logic driven speed for player speed and animation speed, however i dont seem to be able,
When using Animator.Update(MyTimeController.deltaTime);
It seems to run at variable speed, as if the Animator has a second input somewhere.
is there away around this? can you isolate the timeScale from the player/mecanim and have it look at another Time class for input variables?
So time slows down for the world but not the player, think clockstoppers!
c# time unity3d
c# time unity3d
edited Mar 27 '14 at 10:14
asked Mar 22 '14 at 18:30
Theodor Solbjørg
556515
556515
@Bart, following my example? :-p
– Steven
Mar 22 '14 at 19:58
1
Ha @Steven, isn't the first, won't be the last. ;)
– Bart
Mar 22 '14 at 20:06
add a comment |
@Bart, following my example? :-p
– Steven
Mar 22 '14 at 19:58
1
Ha @Steven, isn't the first, won't be the last. ;)
– Bart
Mar 22 '14 at 20:06
@Bart, following my example? :-p
– Steven
Mar 22 '14 at 19:58
@Bart, following my example? :-p
– Steven
Mar 22 '14 at 19:58
1
1
Ha @Steven, isn't the first, won't be the last. ;)
– Bart
Mar 22 '14 at 20:06
Ha @Steven, isn't the first, won't be the last. ;)
– Bart
Mar 22 '14 at 20:06
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
As Felype mentioned, you can use Animator Component, I usually get the Animator component and then use <animator_object>[<animation_clip_object.name>]
.speed. For speed, value of 1 means normal speed.
add a comment |
up vote
0
down vote
Acording to Unity Documentation there's this animation speed property in the animator object:
https://docs.unity3d.com/Documentation/ScriptReference/Animator-speed.html
Try using
<yourgameobjecthere>.getComponent<Animator>().speed = Time.timescale;
right after you set the time scale.
I'm not sure the animation speed is applied correctly during an animation tho.
true, but that still doesnt keep the player at normal speed but sets him to timeScale speed, if time is slowed down by 50% the character should stay normal, as if time doesnt slow down for the player but the world around him, think clockstoppers.
– Theodor Solbjørg
Mar 27 '14 at 10:13
1
My thought was about, if we reduce timescale to 0.5, character speed should go to 2.0 theoretically, thus 1/0.5 = 2.0, if we decrease timescale to 0.25, character speed goes to 1/0.25 = 4.0. Not sure if this would work in practice tho.
– Felype
May 30 '14 at 16:12
1
shoud be fixed. 1/Time.timescale -> Time.timescale
– Jinbom Heo
May 28 at 6:48
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22581778%2fslow-down-time-unity3d-mecanim%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
As Felype mentioned, you can use Animator Component, I usually get the Animator component and then use <animator_object>[<animation_clip_object.name>]
.speed. For speed, value of 1 means normal speed.
add a comment |
up vote
0
down vote
As Felype mentioned, you can use Animator Component, I usually get the Animator component and then use <animator_object>[<animation_clip_object.name>]
.speed. For speed, value of 1 means normal speed.
add a comment |
up vote
0
down vote
up vote
0
down vote
As Felype mentioned, you can use Animator Component, I usually get the Animator component and then use <animator_object>[<animation_clip_object.name>]
.speed. For speed, value of 1 means normal speed.
As Felype mentioned, you can use Animator Component, I usually get the Animator component and then use <animator_object>[<animation_clip_object.name>]
.speed. For speed, value of 1 means normal speed.
answered Mar 23 '14 at 6:20
Karthik
12113
12113
add a comment |
add a comment |
up vote
0
down vote
Acording to Unity Documentation there's this animation speed property in the animator object:
https://docs.unity3d.com/Documentation/ScriptReference/Animator-speed.html
Try using
<yourgameobjecthere>.getComponent<Animator>().speed = Time.timescale;
right after you set the time scale.
I'm not sure the animation speed is applied correctly during an animation tho.
true, but that still doesnt keep the player at normal speed but sets him to timeScale speed, if time is slowed down by 50% the character should stay normal, as if time doesnt slow down for the player but the world around him, think clockstoppers.
– Theodor Solbjørg
Mar 27 '14 at 10:13
1
My thought was about, if we reduce timescale to 0.5, character speed should go to 2.0 theoretically, thus 1/0.5 = 2.0, if we decrease timescale to 0.25, character speed goes to 1/0.25 = 4.0. Not sure if this would work in practice tho.
– Felype
May 30 '14 at 16:12
1
shoud be fixed. 1/Time.timescale -> Time.timescale
– Jinbom Heo
May 28 at 6:48
add a comment |
up vote
0
down vote
Acording to Unity Documentation there's this animation speed property in the animator object:
https://docs.unity3d.com/Documentation/ScriptReference/Animator-speed.html
Try using
<yourgameobjecthere>.getComponent<Animator>().speed = Time.timescale;
right after you set the time scale.
I'm not sure the animation speed is applied correctly during an animation tho.
true, but that still doesnt keep the player at normal speed but sets him to timeScale speed, if time is slowed down by 50% the character should stay normal, as if time doesnt slow down for the player but the world around him, think clockstoppers.
– Theodor Solbjørg
Mar 27 '14 at 10:13
1
My thought was about, if we reduce timescale to 0.5, character speed should go to 2.0 theoretically, thus 1/0.5 = 2.0, if we decrease timescale to 0.25, character speed goes to 1/0.25 = 4.0. Not sure if this would work in practice tho.
– Felype
May 30 '14 at 16:12
1
shoud be fixed. 1/Time.timescale -> Time.timescale
– Jinbom Heo
May 28 at 6:48
add a comment |
up vote
0
down vote
up vote
0
down vote
Acording to Unity Documentation there's this animation speed property in the animator object:
https://docs.unity3d.com/Documentation/ScriptReference/Animator-speed.html
Try using
<yourgameobjecthere>.getComponent<Animator>().speed = Time.timescale;
right after you set the time scale.
I'm not sure the animation speed is applied correctly during an animation tho.
Acording to Unity Documentation there's this animation speed property in the animator object:
https://docs.unity3d.com/Documentation/ScriptReference/Animator-speed.html
Try using
<yourgameobjecthere>.getComponent<Animator>().speed = Time.timescale;
right after you set the time scale.
I'm not sure the animation speed is applied correctly during an animation tho.
edited Jun 4 at 14:08
answered Mar 22 '14 at 20:23
Felype
1,7081326
1,7081326
true, but that still doesnt keep the player at normal speed but sets him to timeScale speed, if time is slowed down by 50% the character should stay normal, as if time doesnt slow down for the player but the world around him, think clockstoppers.
– Theodor Solbjørg
Mar 27 '14 at 10:13
1
My thought was about, if we reduce timescale to 0.5, character speed should go to 2.0 theoretically, thus 1/0.5 = 2.0, if we decrease timescale to 0.25, character speed goes to 1/0.25 = 4.0. Not sure if this would work in practice tho.
– Felype
May 30 '14 at 16:12
1
shoud be fixed. 1/Time.timescale -> Time.timescale
– Jinbom Heo
May 28 at 6:48
add a comment |
true, but that still doesnt keep the player at normal speed but sets him to timeScale speed, if time is slowed down by 50% the character should stay normal, as if time doesnt slow down for the player but the world around him, think clockstoppers.
– Theodor Solbjørg
Mar 27 '14 at 10:13
1
My thought was about, if we reduce timescale to 0.5, character speed should go to 2.0 theoretically, thus 1/0.5 = 2.0, if we decrease timescale to 0.25, character speed goes to 1/0.25 = 4.0. Not sure if this would work in practice tho.
– Felype
May 30 '14 at 16:12
1
shoud be fixed. 1/Time.timescale -> Time.timescale
– Jinbom Heo
May 28 at 6:48
true, but that still doesnt keep the player at normal speed but sets him to timeScale speed, if time is slowed down by 50% the character should stay normal, as if time doesnt slow down for the player but the world around him, think clockstoppers.
– Theodor Solbjørg
Mar 27 '14 at 10:13
true, but that still doesnt keep the player at normal speed but sets him to timeScale speed, if time is slowed down by 50% the character should stay normal, as if time doesnt slow down for the player but the world around him, think clockstoppers.
– Theodor Solbjørg
Mar 27 '14 at 10:13
1
1
My thought was about, if we reduce timescale to 0.5, character speed should go to 2.0 theoretically, thus 1/0.5 = 2.0, if we decrease timescale to 0.25, character speed goes to 1/0.25 = 4.0. Not sure if this would work in practice tho.
– Felype
May 30 '14 at 16:12
My thought was about, if we reduce timescale to 0.5, character speed should go to 2.0 theoretically, thus 1/0.5 = 2.0, if we decrease timescale to 0.25, character speed goes to 1/0.25 = 4.0. Not sure if this would work in practice tho.
– Felype
May 30 '14 at 16:12
1
1
shoud be fixed. 1/Time.timescale -> Time.timescale
– Jinbom Heo
May 28 at 6:48
shoud be fixed. 1/Time.timescale -> Time.timescale
– Jinbom Heo
May 28 at 6:48
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22581778%2fslow-down-time-unity3d-mecanim%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@Bart, following my example? :-p
– Steven
Mar 22 '14 at 19:58
1
Ha @Steven, isn't the first, won't be the last. ;)
– Bart
Mar 22 '14 at 20:06