void FixedUpdate() { if (_moving) { _moveProgress += Time.fixedDeltaTime * MoveSpeed; var moveAmount = Mathf.Clamp(_moveProgress, 0, 1); var to = MazeGenerator.WallCoordToReal(TargetLocation) + Vector3.up * MazeGenerator.BlockScale / 2; var from = MazeGenerator.WallCoordToReal(Location) + Vector3.up * MazeGenerator.BlockScale / 2; if (_moveProgress >= 1) { _moving = false; _moveProgress -= 1; Location = TargetLocation; MazeGenerator.CheckGoal(Location); } transform.localPosition = (to * (moveAmount) + from * (1 - moveAmount)); } if (!_moving) { if (Input.GetAxis("Horizontal") > 0) { Move(Location.Right.To); } if (Input.GetAxis("Horizontal") < 0) { Move(Location.Left.To); } if (Input.GetAxis("Vertical") > 0) { Move(Location.Up.To); } if (Input.GetAxis("Vertical") < 0) { Move(Location.Down.To); } } MazeGenerator.CheckLava(TargetLocation); }