Да, вызовов много, но снизу есть другой скрипт которой вызывается также часто но съедает всего 4% (смотреть картинкуhttps://ibb.co/89KfsNG или https://ibb.co/FBH6Bj5)
Вот код:
Синтаксис:
Используется csharp
botMovmentDirection = color == Colors.blue ? myMainCharacter.direction : myMainCharacter.botDirection;
anim.SetBool("Run", botMovmentDirection != Vector3.zero);
controller.Move(botMovmentDirection * speed * Time.deltaTime);
controller.Move((myMainGmTransform.position + newPos - transform.position) * speed * Time.deltaTime);
LookToDirection(botMovmentDirection);
private void LookToDirection(Vector3 direction)
{
if (direction.magnitude >= 0.1)
{
float targetRotation = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetRotation, ref turnSmoothVecloity, smoothTime);
transform.rotation = Quaternion.Euler(0, angle, 0);
}
}
anim.SetBool("Run", botMovmentDirection != Vector3.zero);
controller.Move(botMovmentDirection * speed * Time.deltaTime);
controller.Move((myMainGmTransform.position + newPos - transform.position) * speed * Time.deltaTime);
LookToDirection(botMovmentDirection);
private void LookToDirection(Vector3 direction)
{
if (direction.magnitude >= 0.1)
{
float targetRotation = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetRotation, ref turnSmoothVecloity, smoothTime);
transform.rotation = Quaternion.Euler(0, angle, 0);
}
}