// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (moveTime <= 0) { moveTime = Random.Range(0.5f, 1f); moveDirection = Random.Range(-0.4f, 0.4f); } else { moveTime -= Time.deltaTime; if (entityData.grounded == true) { movementController.Move(rb, moveDirection, entityData.speed); } else { movementController.AirMove(rb, moveDirection, entityData.speed); } } if (moveDirection > 0) { enemy.transform.localScale = new Vector3(1, 1, 1); } else if (moveDirection < 0) { enemy.transform.localScale = new Vector3(-1, 1, 1); } }
private void PlayerMovementCheck() { if (!canMove) { return; } //Grounded movement if (grounded == true) { movementController.Move(rb, moveDirection.x, moveSpeed); return; } //Air movement movementController.AirMove(rb, moveDirection.x, moveSpeed); }