Question by
MasterVRunner2 · Feb 02, 2018 at 06:17 PM ·
charactercontrollerwindowscharacter controllercharacter movementcodepage
Skipping Movement when in fixed time?
I am trying to make a game where you can run very fast and go into slow motion when you left click. But in slow motion, but the movement is very shaking and skipping. I found out that if I hold both the W and D keys down at the same time I get a smooth movement. It gets even more shaky when I increase my walkSpeed. Here is my code:
public float walkSpeed;
void Update(){
MovePlayer()
}
void MovePlayer(){
float horiz = Input.GetAxis("Horizontal");
float vert = Input.GetAxis("Vertical");
Vector3 moveDirSide = transform.right * horiz * walkSpeed;
Vector3 moveDirForward = transform.forward * vert * walkSpeed;
charControl.SimpleMove(moveDirSide);
charControl.SimpleMove(moveDirForward);
if (Input.GetButtonDown("Fire1"))
{
Debug.Log(Time.fixedDeltaTime);
FlashTime();
}
if (Input.GetButtonDown("Fire2"))
{
FlashTime2();
}
}
void FlashTime ()
{
Time.timeScale = 0.02f;
Time.fixedDeltaTime = Time.timeScale * 0.02f;
}
void FlashTime2 ()
{
Time.timeScale = 1;
Time.fixedDeltaTime = Time.timeScale * 0.02f;
}
Does anyone know whats wrong?
Comment