Question by
MaxWehrle · Jul 13, 2021 at 10:20 AM ·
collisioncharactercontrollermovement scriptlagsbackward
Movement with CharacterController is lagging while moving backward
Hey ho, i have a little problem in unity. Currently im coding a base for a game, with a character, character movement, health system etc. Now my character is moving by pressing WASD and its actually working, but if i press S to move backward, my character moves extremely slow, the view begins to shake and it seems like the character has collision problems with the ground or something like this. Does anybody knows this issue and maybe also a solution? (:
Here is my code of the movement part:
// Movement by WASD
move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
move = cameraTransform.TransformDirection(move);
if (!this.death)
{
if (!running && groundedPlayer)
{
controller.Move(move * Time.deltaTime * playerSpeed);
}
else if (running && groundedPlayer)
{
controller.Move(move * Time.deltaTime * runningSpeed);
}
else if (running && !groundedPlayer && !Input.GetKey(KeyCode.S))
{
controller.Move(move * Time.deltaTime * jumpSpeedRunning);
}
else if (!running && !groundedPlayer && !Input.GetKey(KeyCode.S))
{
controller.Move(move * Time.deltaTime * jumpSpeed);
}
}
Comment