- Home /
Question by
SylvesterAHansen · Jul 17, 2016 at 08:37 PM ·
mathmathftimescaledeltatime
Math.Abs slows down on time.timescale
Hey People,
So I have a question regarding Math.abs and time.timescale. See, I have this game where I slow down time for every enemy in the game, but I want for the player character to be able to more around to their hearts content. However, while my character can move around completely freely on time.timescale = 1, The math is slowed down, when I set the time.timescale = 0.01. I would like to the math to remain immediate. So My question is this, how do I divorce Math.Abs from time.deltatime
This is my code:
void Update(){
Time.timeScale = 0.01;
moveDirection = new Vector3 (Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
float aniX = Mathf.Abs (moveDirection.x);
float aniZ = Mathf.Abs (moveDirection.z);
if (aniX > 0.1 || aniZ > 0.1) {
Character.transform.rotation = Quaternion.LookRotation (moveDirection);
aniRun = true;
} else {
aniRun = false;
}
transform.position += moveDirection * speed * Time.unscaledDeltaTime;
}
Comment