Search Unity

Bug Does anyone know what can be done?

Discussion in 'Unity Hub' started by ALidskiy, Nov 19, 2023.

  1. ALidskiy

    ALidskiy

    Joined:
    Jun 27, 2023
    Posts:
    4
    Does anyone know what can be done?

    All of my game mechanics are registered through FixedUpdate(Namely MouseLook and Moving), and in the enemy animation they are registered through OnStateUpdate, as a result it turns out that the enemy moves jerkily if I move relative to him.

    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
    if (agent.remainingDistance <= agent.stoppingDistance)
    agent.SetDestination(points[Random.Range(0, points.Count)].position);

    timer += Time.deltaTime;
    if (timer > 10)
    animator.SetBool("IsPatrolling", false);
    }