Created
September 1, 2023 20:51
-
-
Save DeoEsor/de84e8f75782d3ca9bdf64b5e714b252 to your computer and use it in GitHub Desktop.
ХУЯК ЕБАК И В ПРОД
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float horizontalInput = Input.GetAxis("Horizontal"); | |
float verticalInput = Input.GetAxis("Vertical"); | |
Debug.Log(horizontalInput + " " + verticalInput); | |
//**************************** | |
// HP MANAGEMENT SEGMENET | |
if(xp<15) //кто блять HP назвал xp | |
UIManager.GetInstance().UIDamaged(); | |
//**************************** | |
if (Input.GetKey(KeyCode.Space)) // спринт при нажатии на пробел | |
{ | |
speed = sprintSpeed; | |
} | |
else speed = maxSpeed; | |
//спринт переделать, хрень | |
float rotation; | |
if (horizontalInput < 0) //флипает спрайт при инпуте | |
sprt.flipY = true; | |
else if (horizontalInput > 0) | |
sprt.flipY = false; | |
if (verticalInput != 0f || horizontalInput != 0f) | |
{ | |
rotation = Mathf.Atan2(verticalInput, horizontalInput) * Mathf.Rad2Deg; | |
transform.localEulerAngles = new Vector3(0, 0, rotation); | |
} | |
else if (verticalInput == 0f && horizontalInput == 0f) | |
{ | |
int Yrot = sprt.flipY switch //в зависимости от того, перевёрнут или нет спрайт нужно крутить для Idle в разные стороны | |
{ | |
true => 180, | |
false => 0, | |
}; | |
if (Yrot == 180) | |
{ | |
lt.gameObject.transform.Rotate(0, 180, 0); | |
} | |
else | |
lt.gameObject.transform.Rotate(0, 0, 0); | |
transform.localEulerAngles = new Vector3(0, 0, Yrot); //Рот ебал два дня эту функцию писать | |
} | |
Vector2 movement = new Vector2(horizontalInput, verticalInput).normalized; | |
if (movement == Vector2.zero) pAnimator.SetBool("IsMoving", false); | |
else pAnimator.SetBool("IsMoving", true); | |
pMovement.MovePosition(pMovement.position + movement * speed * Time.fixedDeltaTime); // добавила скорость |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ну а вообще
Ну декомпозировать тут все к хуям надо
Update должны быть маленькие